Background

This file is designed to use CDC data to assess coronavirus disease burden by state, including creating and analyzing state-level clusters.

Through March 7, 2021, The COVID Tracking Project collected and integrated data on tests, cases, hospitalizations, deaths, and the like by state and date. The latest code for using this data is available in Coronavirus_Statistics_CTP_v004.Rmd.

The COVID Tracking Project suggest that US federal data sources are now sufficiently robust to be used for analyses that previously relied on COVID Tracking Project. This code is an attempt to update modules in Coronavirus_Statistics_CTP_v004.Rmd to leverage US federal data.

The code in this module builds on code available in _v002 to include vaccines data:

Broadly, the CDC data analyzed by this module includes:

Functions and Mapping Files

The tidyverse package is loaded and functions are sourced:

# The tidyverse functions are routinely used without package::function format
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.1.1     v dplyr   1.0.6
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
# Functions are available in source file
source("./Generic_Added_Utility_Functions_202105_v001.R")
source("./Coronavirus_CDC_Daily_Functions_v001.R")

A series of mapping files are also available to allow for parameterized processing. Mappings include:

These default parameters are maintained in a separate .R file and can be sourced:

source("./Coronavirus_CDC_Daily_Default_Mappings_v002.R")

Example for Comparison to Previous

The function is tested on existing, previously downloaded data:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210801.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210801.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210801.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210708")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210708")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210728_vaxonly")$dfRaw$vax
                    )

cdc_daily_210801_test <- readRunCDCDaily(thruLabel="Jul 31, 2021", 
                                         downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                         readFrom=readList,
                                         compareFile=compareList, 
                                         writeLog=NULL, 
                                         useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                         weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                            "vxcpm7", "vxcgte65pct"
                                                            ),
                                         skipAssessmentPlots=FALSE, 
                                         brewPalette="Paired"
                                         )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 25
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths      143      152        9 0.06101695
## 2   2020-02-03 tot_deaths      143      152        9 0.06101695
## 3   2020-02-04 tot_deaths      143      152        9 0.06101695
## 4   2020-02-05 tot_deaths      143      152        9 0.06101695
## 5   2020-02-06 tot_deaths      143      152        9 0.06101695
## 6   2020-02-07 tot_deaths      143      152        9 0.06101695
## 7   2020-02-08 tot_deaths      144      153        9 0.06060606
## 8   2020-02-09 tot_deaths      144      153        9 0.06060606
## 9   2020-02-10 tot_deaths      144      153        9 0.06060606
## 10  2020-02-11 tot_deaths      144      153        9 0.06060606
## 11  2020-02-12 tot_deaths      144      153        9 0.06060606
## 12  2020-02-13 tot_deaths      144      153        9 0.06060606
## 13  2020-02-14 tot_deaths      144      153        9 0.06060606
## 14  2020-02-15 tot_deaths      144      153        9 0.06060606
## 15  2020-02-16 tot_deaths      144      153        9 0.06060606
## 16  2020-02-17 tot_deaths      144      153        9 0.06060606
## 17  2020-02-18 tot_deaths      144      153        9 0.06060606
## 18  2020-02-19 tot_deaths      145      154        9 0.06020067
## 19  2020-02-20 tot_deaths      145      154        9 0.06020067
## 20  2020-02-21 tot_deaths      145      154        9 0.06020067
## 21  2020-02-22 tot_deaths      145      154        9 0.06020067
## 22  2020-02-23 tot_deaths      145      154        9 0.06020067
## 23  2020-02-24 tot_deaths      145      154        9 0.06020067
## 24  2020-02-25 tot_deaths      145      154        9 0.06020067
## 25  2020-02-26 tot_deaths      145      154        9 0.06020067
## 26  2020-02-27 tot_deaths      146      155        9 0.05980066
## 27  2020-02-28 tot_deaths      146      155        9 0.05980066
## 28  2020-02-29 tot_deaths      147      156        9 0.05940594
## 29  2020-03-01 tot_deaths      147      156        9 0.05940594
## 30  2020-03-02 tot_deaths      153      162        9 0.05714286
## 31  2020-03-03 tot_deaths      156      165        9 0.05607477
## 32  2020-03-04 tot_deaths      158      167        9 0.05538462
## 33  2020-03-05 tot_deaths      160      169        9 0.05471125
## 34  2020-03-06 tot_deaths      163      172        9 0.05373134
## 35  2020-03-07 tot_deaths      168      177        9 0.05217391
## 36  2020-03-08 tot_deaths      173      182        9 0.05070423
## 37  2020-02-02  tot_cases      510      612      102 0.18181818
## 38  2020-02-03  tot_cases      542      644      102 0.17200675
## 39  2020-02-04  tot_cases      550      652      102 0.16971714
## 40  2020-02-05  tot_cases      555      657      102 0.16831683
## 41  2020-02-06  tot_cases      557      658      101 0.16625514
## 42  2020-02-07  tot_cases      562      663      101 0.16489796
## 43  2020-02-08  tot_cases      570      670      100 0.16129032
## 44  2020-02-09  tot_cases      605      705      100 0.15267176
## 45  2020-02-10  tot_cases      614      713       99 0.14920874
## 46  2020-02-11  tot_cases      625      721       96 0.14264487
## 47  2020-02-12  tot_cases      635      731       96 0.14055637
## 48  2020-02-13  tot_cases      641      736       95 0.13798112
## 49  2020-02-14  tot_cases      649      743       94 0.13505747
## 50  2020-02-15  tot_cases      654      748       94 0.13409415
## 51  2020-02-16  tot_cases      667      758       91 0.12771930
## 52  2020-02-17  tot_cases      685      776       91 0.12457221
## 53  2020-02-18  tot_cases      692      783       91 0.12338983
## 54  2020-02-19  tot_cases      709      799       90 0.11936340
## 55  2020-02-20  tot_cases      723      811       88 0.11473272
## 56  2020-02-21  tot_cases      742      829       87 0.11075748
## 57  2020-02-22  tot_cases      768      855       87 0.10720887
## 58  2020-02-23  tot_cases      792      877       85 0.10185740
## 59  2020-02-24  tot_cases      811      896       85 0.09958992
## 60  2020-02-25  tot_cases      835      920       85 0.09686610
## 61  2020-02-26  tot_cases      879      963       84 0.09120521
## 62  2020-02-27  tot_cases      916      998       82 0.08568443
## 63  2020-02-28  tot_cases      968     1049       81 0.08031730
## 64  2020-02-29  tot_cases     1005     1087       82 0.07839388
## 65  2020-03-01  tot_cases     1094     1177       83 0.07309555
## 66  2020-03-02  tot_cases     1172     1254       82 0.06760099
## 67  2020-03-03  tot_cases     1343     1424       81 0.05854716
## 68  2020-03-04  tot_cases     1482     1565       83 0.05447982
## 69  2021-07-05 new_deaths      104       37       67 0.95035461
## 70  2021-07-04 new_deaths       98       38       60 0.88235294
## 71  2021-01-18 new_deaths     2674     1130     1544 0.81177708
## 72  2021-07-03 new_deaths      140       86       54 0.47787611
## 73  2021-01-19 new_deaths     3036     4578     1542 0.40504334
## 74  2020-12-26 new_deaths     2248     3093      845 0.31642015
## 75  2020-12-24 new_deaths     3274     2463      811 0.28272616
## 76  2021-06-27 new_deaths      139      105       34 0.27868852
## 77  2021-06-20 new_deaths      176      145       31 0.19314642
## 78  2021-06-26 new_deaths      172      142       30 0.19108280
## 79  2021-06-19 new_deaths      180      154       26 0.15568862
## 80  2021-06-28 new_deaths      193      170       23 0.12672176
## 81  2021-06-24 new_deaths      287      258       29 0.10642202
## 82  2021-06-17 new_deaths      334      302       32 0.10062893
## 83  2021-06-23 new_deaths      310      281       29 0.09813875
## 84  2021-06-25 new_deaths      300      273       27 0.09424084
## 85  2021-06-22 new_deaths      283      258       25 0.09242144
## 86  2021-06-18 new_deaths      210      192       18 0.08955224
## 87  2021-06-13 new_deaths      200      184       16 0.08333333
## 88  2021-05-30 new_deaths      237      220       17 0.07439825
## 89  2020-03-21 new_deaths      114      107        7 0.06334842
## 90  2021-06-11 new_deaths      326      306       20 0.06329114
## 91  2021-06-16 new_deaths      310      293       17 0.05638474
## 92  2021-06-15 new_deaths      336      319       17 0.05190840
## 93  2020-02-02  new_cases        1      557      556 1.99283154
## 94  2021-07-05  new_cases    11563     3575     7988 1.05535738
## 95  2021-07-04  new_cases    12794     4156     8638 1.01923304
## 96  2021-07-03  new_cases    14978     5887     9091 0.87141145
## 97  2021-06-10  new_cases    16732    12363     4369 0.30032652
## 98  2021-01-18  new_cases   138853   107646    31207 0.25320184
## 99  2021-01-19  new_cases   145009   176292    31283 0.19472706
## 100 2021-07-02  new_cases    16830    14183     2647 0.17070261
## 101 2021-06-20  new_cases     9228     7787     1441 0.16937996
## 102 2020-12-24  new_cases   222824   195402    27422 0.13113484
## 103 2021-06-01  new_cases     9689     8540     1149 0.12606287
## 104 2021-01-29  new_cases   156344   139722    16622 0.11228577
## 105 2020-12-26  new_cases   151874   169350    17476 0.10880881
## 106 2021-06-30  new_cases    17295    15526     1769 0.10779684
## 107 2021-06-28  new_cases     9690     8701      989 0.10755261
## 108 2021-06-09  new_cases    19404    21526     2122 0.10368923
## 109 2021-01-09  new_cases   249812   226455    23357 0.09808364
## 110 2021-01-30  new_cases   137321   150808    13487 0.09361779
## 111 2021-07-01  new_cases    18730    17149     1581 0.08812955
## 112 2021-06-08  new_cases    14356    15667     1311 0.08733304
## 113 2021-06-29  new_cases    16159    15051     1108 0.07100288
## 114 2021-06-06  new_cases    12102    11304      798 0.06818764
## 115 2020-07-14  new_cases    65684    61818     3866 0.06064219
## 116 2021-01-08  new_cases   295289   312357    17068 0.05617745
## 117 2021-05-24  new_cases    15657    14828      829 0.05438740
## 118 2021-05-31  new_cases     9193     9700      507 0.05367067
## 119 2021-05-03  new_cases    33239    31601     1638 0.05052437
## 120 2021-06-07  new_cases    10122    10644      522 0.05027449
## 121 2020-07-15  new_cases    70320    73939     3619 0.05017365

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     IN tot_deaths   3407157   3378244    28913 0.008522120
## 2     SC tot_deaths   2291589   2305862    14273 0.006209093
## 3     CA tot_deaths  14183041  14129523    53518 0.003780512
## 4     NC tot_deaths   3073917   3062861    11056 0.003603194
## 5     MS tot_deaths   1998075   1991323     6752 0.003384972
## 6     KY tot_deaths   1634463   1630052     4411 0.002702392
## 7     RI tot_deaths    749883    751479     1596 0.002126070
## 8     NM tot_deaths   1001515    999916     1599 0.001597857
## 9     AL tot_deaths   2742024   2738028     3996 0.001458380
## 10    CA  tot_cases 865747767 837321729 28426038 0.033382123
## 11    SC  tot_cases 129358076 129977727   619651 0.004778754
## 12    RI  tot_cases  32453898  32591078   137180 0.004218004
## 13    AL  tot_cases 131847795 131406619   441176 0.003351708
## 14    MI  tot_cases 214132223 214386719   254496 0.001187793
## 15    MS  tot_cases  77187328  77104046    83282 0.001079542
## 16    MS new_deaths      7432      7332      100 0.013546464
## 17    NM new_deaths      4382      4344       38 0.008709603
## 18    CA new_deaths     63517     62992      525 0.008299805
## 19    KY new_deaths      7285      7229       56 0.007716687
## 20    NC new_deaths     13517     13434       83 0.006159326
## 21    AL new_deaths     11430     11360       70 0.006143045
## 22    MI new_deaths     21076     20995       81 0.003850633
## 23    IN new_deaths     13914     13863       51 0.003672103
## 24    TX new_deaths     51507     51349      158 0.003072256
## 25    TN new_deaths     12611     12576       35 0.002779211
## 26    WA new_deaths      5954      5939       15 0.002522492
## 27    RI new_deaths      2736      2730        6 0.002195390
## 28    UT new_deaths      2371      2368        3 0.001266090
## 29    CA  new_cases   3880232   3713944   166288 0.043793560
## 30    VI  new_cases      3932      3916       16 0.004077472
## 31    MS  new_cases    323003    321780     1223 0.003793524
## 32    AL  new_cases    554270    552325     1945 0.003515288
## 33    LA  new_cases    483605    482096     1509 0.003125191
## 34    NV  new_cases    335771    334763     1008 0.003006559
## 35    FL  new_cases   2344516   2337613     6903 0.002948659
## 36    WY  new_cases     62592     62445      147 0.002351304
## 37    UT  new_cases    416971    416110      861 0.002067026
## 38    KS  new_cases    319154    318515      639 0.002004175
## 39    WA  new_cases    453368    452483      885 0.001953964
## 40    AK  new_cases     68595     68478      117 0.001707120
## 41    MI  new_cases   1002081   1000375     1706 0.001703908
## 42    OR  new_cases    209377    209035      342 0.001634752
## 43    NC  new_cases   1015407   1014359     1048 0.001032631
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 33,360
## Columns: 15
## $ date           <date> 2021-02-02, 2020-07-30, 2020-05-03, 2020-12-04, 2021-0~
## $ state          <chr> "IL", "ME", "NH", "IN", "CA", "GU", "CT", "WI", "NV", "~
## $ tot_cases      <dbl> 1130917, 3910, 2518, 367338, 3409079, 0, 267337, 98440,~
## $ conf_cases     <dbl> 1130917, 3497, NA, NA, 3285871, NA, 250915, 92712, NA, ~
## $ prob_cases     <dbl> 0, 413, NA, NA, 123208, NA, 16422, 5728, NA, 105447, NA~
## $ new_cases      <dbl> 2304, 22, 89, 7899, 18703, 0, 0, 1502, 128, 199, 0, 394~
## $ pnew_case      <dbl> 0, 2, 0, 0, 892, NA, 0, 94, 0, 47, NA, 5, 102, NA, 0, 0~
## $ tot_deaths     <dbl> 21336, 123, 86, 7031, 49603, 0, 7381, 1237, 5586, 21047~
## $ conf_death     <dbl> 19306, 122, NA, 6746, 49603, NA, 6049, 1228, NA, 19789,~
## $ prob_death     <dbl> 2030, 1, NA, 285, 0, NA, 1332, 9, NA, 1258, NA, NA, 0, ~
## $ new_deaths     <dbl> 63, 2, 2, 91, 494, 0, 0, 8, 0, 6, 0, 32, 60, 6, 2, 39, ~
## $ pnew_death     <dbl> 16, 0, 0, 1, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 7, 0, ~
## $ created_at     <chr> "02/03/2021 02:55:58 PM", "07/31/2020 02:35:06 PM", "05~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", "Not agree", "Agree", "N~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", "Agree", "Agree", "Not a~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2021-07-02 hosp_ped      662      597       65 0.10325655
## 2 2021-07-03 hosp_ped      638      597       41 0.06639676

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   523814   518483     5331 0.010229330
## 2     TN        inp   558512   559654     1142 0.002042631
## 3     NM        inp   137802   137991      189 0.001370593
## 4     NH   hosp_ped      271      361       90 0.284810127
## 5     ME   hosp_ped      452      509       57 0.118626431
## 6     KY   hosp_ped     5518     5308      210 0.038795492
## 7     MA   hosp_ped     5015     5201      186 0.036413469
## 8     AR   hosp_ped     5977     5840      137 0.023186934
## 9     TN   hosp_ped     7924     8102      178 0.022213902
## 10    DE   hosp_ped     1647     1683       36 0.021621622
## 11    AL   hosp_ped     7711     7555      156 0.020437574
## 12    WV   hosp_ped     2226     2269       43 0.019132369
## 13    KS   hosp_ped     1711     1679       32 0.018879056
## 14    NV   hosp_ped     1999     2037       38 0.018830525
## 15    AZ   hosp_ped    11435    11266      169 0.014889212
## 16    VA   hosp_ped     6604     6513       91 0.013875124
## 17    IN   hosp_ped     6913     6826       87 0.012664677
## 18    MS   hosp_ped     3727     3686       41 0.011061648
## 19    MO   hosp_ped    15406    15241      165 0.010767775
## 20    SC   hosp_ped     2706     2679       27 0.010027855
## 21    PA   hosp_ped    19857    20010      153 0.007675521
## 22    WA   hosp_ped     4288     4263       25 0.005847269
## 23    NM   hosp_ped     3125     3107       18 0.005776637
## 24    IA   hosp_ped     2275     2287       12 0.005260851
## 25    CO   hosp_ped     9355     9401       46 0.004905097
## 26    NJ   hosp_ped     9108     9142       34 0.003726027
## 27    OH   hosp_ped    25500    25406       94 0.003693081
## 28    IL   hosp_ped    19711    19644       67 0.003404904
## 29    GA   hosp_ped    21902    21973       71 0.003236467
## 30    MT   hosp_ped     1022     1025        3 0.002931119
## 31    PR   hosp_ped    11353    11380       27 0.002375401
## 32    CA   hosp_ped    30719    30667       52 0.001694197
## 33    LA   hosp_ped     3174     3179        5 0.001574059
## 34    TX   hosp_ped    38680    38739       59 0.001524174
## 35    FL   hosp_ped    54840    54921       81 0.001475934
## 36    HI   hosp_ped      720      721        1 0.001387925
## 37    NC   hosp_ped    10619    10606       13 0.001224971
## 38    AL hosp_adult   443621   439848     3773 0.008541330
## 39    TN hosp_adult   494022   494969      947 0.001915083
## 40    NM hosp_adult   112634   112842      208 0.001844986
## 41    ME hosp_adult    37173    37121       52 0.001399844
## 42    WV hosp_adult   126618   126444      174 0.001375157
## 43    KY hosp_adult   299353   299757      404 0.001348667
## 44    NH hosp_adult    39064    39014       50 0.001280771
## 45    CA hosp_adult  2422197  2425080     2883 0.001189534
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 27,682
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 4
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 14,918
## Columns: 69
## $ date                                   <date> 2021-07-31, 2021-07-31, 2021-0~
## $ MMWR_week                              <dbl> 30, 30, 30, 30, 30, 30, 30, 30,~
## $ state                                  <chr> "AK", "NM", "PR", "RP", "MS", "~
## $ Distributed                            <dbl> 854805, 2449685, 4266370, 28650~
## $ Distributed_Janssen                    <dbl> 59300, 138500, 190000, 3800, 16~
## $ Distributed_Moderna                    <dbl> 366220, 1066860, 1853400, 20800~
## $ Distributed_Pfizer                     <dbl> 429285, 1244325, 2222970, 4050,~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 116849, 116828, 133587, 159993,~
## $ Distributed_Per_100k_12Plus            <dbl> 140390, 137051, 149787, 187353,~
## $ Distributed_Per_100k_18Plus            <dbl> 154979, 151123, 162779, 205421,~
## $ Distributed_Per_100k_65Plus            <dbl> 933315, 648741, 785808, 944298,~
## $ vxa                                    <dbl> 697440, 2487536, 3975244, 26286~
## $ Administered_12Plus                    <dbl> 695366, 2487278, 3973905, 26286~
## $ Administered_18Plus                    <dbl> 653874, 2330829, 3705211, 25597~
## $ Administered_65Plus                    <dbl> 143058, 664378, 1048492, 3120, ~
## $ Administered_Janssen                   <dbl> 28437, 87616, 114212, 2145, 637~
## $ Administered_Moderna                   <dbl> 289116, 1081538, 1691040, 23441~
## $ Administered_Pfizer                    <dbl> 379706, 1313894, 2169642, 700, ~
## $ Administered_Unk_Manuf                 <dbl> 181, 4488, 350, 0, 1047, 727, 0~
## $ Administered_Fed_LTC                   <dbl> 6640, 39710, 74284, 0, 54224, 1~
## $ Administered_Fed_LTC_Residents         <dbl> 2078, 11847, 11431, 0, 26288, 8~
## $ Administered_Fed_LTC_Staff             <dbl> 1378, 12139, 10950, 0, 12915, 5~
## $ Administered_Fed_LTC_Unk               <dbl> 3184, 15724, 51903, 0, 15021, 3~
## $ Administered_Fed_LTC_Dose1             <dbl> 4300, 24065, 53094, 0, 31843, 1~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 1383, 6414, 7925, 0, 14433, 507~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 956, 6649, 7461, 0, 7685, 36183~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 1961, 11002, 37708, 0, 9725, 29~
## $ Admin_Per_100k                         <dbl> 95338, 118633, 124472, 146792, ~
## $ Admin_Per_100k_12Plus                  <dbl> 114205, 139154, 139519, 171894,~
## $ Admin_Per_100k_18Plus                  <dbl> 118550, 143790, 141368, 183531,~
## $ Admin_Per_100k_65Plus                  <dbl> 156197, 175945, 193118, 102835,~
## $ Recip_Administered                     <dbl> 692140, 2511859, 4003254, 26519~
## $ Administered_Dose1_Recip               <dbl> 376882, 1374231, 2197391, 15199~
## $ Administered_Dose1_Pop_Pct             <dbl> 51.5, 65.5, 68.8, 84.9, 39.8, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 375603, 1373997, 2196318, 15199~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 61.7, 76.9, 77.1, 99.4, 46.9, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 352303, 1282733, 2045507, 14508~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 63.9, 79.1, 78.0, 99.9, 50.0, 6~
## $ Administered_Dose1_Recip_65Plus        <dbl> 75867, 359328, 564728, 1707, 38~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 82.8, 95.2, 99.9, 56.3, 78.6, 9~
## $ vxc                                    <dbl> 333092, 1198386, 1911719, 13461~
## $ vxcpoppct                              <dbl> 45.5, 57.2, 59.9, 75.2, 34.5, 5~
## $ Series_Complete_12Plus                 <dbl> 332299, 1198314, 1911408, 13461~
## $ Series_Complete_12PlusPop_Pct          <dbl> 54.6, 67.0, 67.1, 88.0, 40.7, 6~
## $ vxcgte18                               <dbl> 314089, 1126808, 1790751, 13461~
## $ vxcgte18pct                            <dbl> 56.9, 69.5, 68.3, 96.5, 44.0, 6~
## $ vxcgte65                               <dbl> 71390, 324959, 506358, 1671, 35~
## $ vxcgte65pct                            <dbl> 77.9, 86.1, 93.3, 55.1, 72.7, 8~
## $ Series_Complete_Janssen                <dbl> 26386, 86064, 113821, 2148, 627~
## $ Series_Complete_Moderna                <dbl> 133838, 492367, 784508, 11283, ~
## $ Series_Complete_Pfizer                 <dbl> 172824, 618609, 1013352, 30, 52~
## $ Series_Complete_Unk_Manuf              <dbl> 44, 1346, 38, 0, 138, 318, 0, 1~
## $ Series_Complete_Janssen_12Plus         <dbl> 26384, 86052, 113778, 2148, 627~
## $ Series_Complete_Moderna_12Plus         <dbl> 133834, 492349, 784456, 11283, ~
## $ Series_Complete_Pfizer_12Plus          <dbl> 172037, 618567, 1013136, 30, 52~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 44, 1346, 38, 0, 138, 318, 0, 1~
## $ Series_Complete_Janssen_18Plus         <dbl> 26261, 85937, 113673, 2148, 626~
## $ Series_Complete_Moderna_18Plus         <dbl> 133469, 492021, 784182, 11283, ~
## $ Series_Complete_Pfizer_18Plus          <dbl> 154318, 547516, 892859, 30, 495~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 41, 1334, 37, 0, 133, 309, 0, 1~
## $ Series_Complete_Janssen_65Plus         <dbl> 2638, 18271, 19965, 212, 15374,~
## $ Series_Complete_Moderna_65Plus         <dbl> 40125, 151102, 257623, 1450, 18~
## $ Series_Complete_Pfizer_65Plus          <dbl> 28605, 154857, 228764, 9, 15393~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 22, 729, 6, 0, 60, 135, 0, 734,~
## $ Series_Complete_FedLTC                 <dbl> 2320, 15515, 21185, 0, 22390, 6~
## $ Series_Complete_FedLTC_Residents       <dbl> 676, 5246, 3503, 0, 11688, 3467~
## $ Series_Complete_FedLTC_Staff           <dbl> 425, 5319, 3488, 0, 5176, 23209~
## $ Series_Complete_FedLTC_Unknown         <dbl> 1219, 4950, 14194, 0, 5526, 782~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   8.21e+9    1.64e+8   3.49e+7 604596       32804    
## 2 after    8.17e+9    1.63e+8   3.47e+7 601834       28356    
## 3 pctchg   4.40e-3    3.96e-3   4.58e-3      0.00457     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 28,356
## Columns: 6
## $ date       <date> 2021-02-02, 2020-07-30, 2020-05-03, 2020-12-04, 2021-01-28~
## $ state      <chr> "IL", "ME", "NH", "IN", "CA", "CT", "WI", "NV", "MI", "MI",~
## $ tot_cases  <dbl> 1130917, 3910, 2518, 367338, 3409079, 267337, 98440, 324132~
## $ tot_deaths <dbl> 21336, 123, 86, 7031, 49603, 7381, 1237, 5586, 21047, 0, 11~
## $ new_cases  <dbl> 2304, 22, 89, 7899, 18703, 0, 1502, 128, 199, 0, 394, 3436,~
## $ new_deaths <dbl> 63, 2, 2, 91, 494, 0, 8, 0, 6, 0, 32, 60, 6, 2, 39, 66, 0, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 2.78e+7    2.19e+7 471723      27682     
## 2 after  2.77e+7    2.18e+7 459822      26679     
## 3 pctchg 5.58e-3    5.57e-3      0.0252     0.0362
## 
## 
## Processed for cdcHosp:
## Rows: 26,679
## Columns: 5
## $ date       <date> 2020-07-22, 2020-07-20, 2020-07-19, 2020-07-18, 2020-07-18~
## $ state      <chr> "IA", "IA", "ND", "IA", "ND", "TX", "OK", "CT", "ND", "NM",~
## $ inp        <dbl> 0, 1, 46, 10, 33, 12003, 678, 215, 16, 119, 51, 19, 250, 14~
## $ hosp_adult <dbl> 0, 1, NA, 10, NA, 7999, 566, 115, NA, NA, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> 0, 0, NA, 0, NA, 194, 9, 0, NA, NA, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 8.19e+10 3.37e+10 302401.    1.10e+10 561791.     3.28e+10  373517.   
## 2 after  3.89e+10 1.63e+10 255914.    5.34e+ 9 512134.     1.59e+10  320269.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.154 5.16e- 1      0.0884 5.16e- 1       0.143
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 11,730
## Columns: 9
## $ date        <date> 2021-07-31, 2021-07-31, 2021-07-31, 2021-07-31, 2021-07-3~
## $ state       <chr> "AK", "NM", "MS", "WI", "NY", "OK", "MD", "NH", "WV", "AL"~
## $ vxa         <dbl> 697440, 2487536, 2150026, 6163565, 22950250, 3460262, 7213~
## $ vxc         <dbl> 333092, 1198386, 1026837, 3015017, 11109858, 1593194, 3559~
## $ vxcpoppct   <dbl> 45.5, 57.2, 34.5, 51.8, 57.1, 40.3, 58.9, 58.3, 39.0, 34.3~
## $ vxcgte65    <dbl> 71390, 324959, 353642, 895738, 2663975, 482309, 844122, 22~
## $ vxcgte65pct <dbl> 77.9, 86.1, 72.7, 88.1, 80.8, 75.9, 88.0, 87.4, 70.2, 69.5~
## $ vxcgte18    <dbl> 314089, 1126808, 1001545, 2875753, 10577357, 1533309, 3342~
## $ vxcgte18pct <dbl> 56.9, 69.5, 44.0, 63.1, 68.6, 51.0, 71.0, 68.2, 46.9, 43.1~
## 
## Integrated per capita data file:
## Rows: 28,569
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

all.equal(names(cdc_daily_210801_test), names(readFromRDS("cdc_daily_210801")))
## [1] TRUE
sapply(names(cdc_daily_210801_test), FUN=function(x)
    identical(cdc_daily_210801_test[[x]], readFromRDS("cdc_daily_210801")[[x]])
    )
##    stateData        dfRaw    dfProcess  dfPerCapita  useClusters plotDataList 
##         TRUE         TRUE         TRUE         TRUE         TRUE        FALSE
sapply(names(cdc_daily_210801_test$plotDataList), FUN=function(x)
    identical(cdc_daily_210801_test$plotDataList[[x]], readFromRDS("cdc_daily_210801")$plotDataList[[x]])
    )
##       dfFull        dfAgg plotClusters summaryPlots     detPlots 
##         TRUE         TRUE         TRUE        FALSE        FALSE

As expected, all data elements are identical. Plot environments change with each creation, so the plot objects are not identical.

The latest data are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210804.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210804.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210804.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210708")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210708")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210728_vaxonly")$dfRaw$vax
                    )

cdc_daily_210804 <- readRunCDCDaily(thruLabel="Aug 3, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths      143      152        9 0.06101695
## 2   2020-02-03 tot_deaths      143      152        9 0.06101695
## 3   2020-02-04 tot_deaths      143      152        9 0.06101695
## 4   2020-02-05 tot_deaths      143      152        9 0.06101695
## 5   2020-02-06 tot_deaths      143      152        9 0.06101695
## 6   2020-02-07 tot_deaths      143      152        9 0.06101695
## 7   2020-02-08 tot_deaths      144      153        9 0.06060606
## 8   2020-02-09 tot_deaths      144      153        9 0.06060606
## 9   2020-02-10 tot_deaths      144      153        9 0.06060606
## 10  2020-02-11 tot_deaths      144      153        9 0.06060606
## 11  2020-02-12 tot_deaths      144      153        9 0.06060606
## 12  2020-02-13 tot_deaths      144      153        9 0.06060606
## 13  2020-02-14 tot_deaths      144      153        9 0.06060606
## 14  2020-02-15 tot_deaths      144      153        9 0.06060606
## 15  2020-02-16 tot_deaths      144      153        9 0.06060606
## 16  2020-02-17 tot_deaths      144      153        9 0.06060606
## 17  2020-02-18 tot_deaths      144      153        9 0.06060606
## 18  2020-02-19 tot_deaths      145      154        9 0.06020067
## 19  2020-02-20 tot_deaths      145      154        9 0.06020067
## 20  2020-02-21 tot_deaths      145      154        9 0.06020067
## 21  2020-02-22 tot_deaths      145      154        9 0.06020067
## 22  2020-02-23 tot_deaths      145      154        9 0.06020067
## 23  2020-02-24 tot_deaths      145      154        9 0.06020067
## 24  2020-02-25 tot_deaths      145      154        9 0.06020067
## 25  2020-02-26 tot_deaths      145      154        9 0.06020067
## 26  2020-02-27 tot_deaths      146      155        9 0.05980066
## 27  2020-02-28 tot_deaths      146      155        9 0.05980066
## 28  2020-02-29 tot_deaths      147      156        9 0.05940594
## 29  2020-03-01 tot_deaths      147      156        9 0.05940594
## 30  2020-03-02 tot_deaths      153      162        9 0.05714286
## 31  2020-03-03 tot_deaths      156      165        9 0.05607477
## 32  2020-03-04 tot_deaths      158      167        9 0.05538462
## 33  2020-03-05 tot_deaths      160      169        9 0.05471125
## 34  2020-03-06 tot_deaths      163      172        9 0.05373134
## 35  2020-03-07 tot_deaths      168      177        9 0.05217391
## 36  2020-03-08 tot_deaths      173      182        9 0.05070423
## 37  2020-02-02  tot_cases      510      612      102 0.18181818
## 38  2020-02-03  tot_cases      542      644      102 0.17200675
## 39  2020-02-04  tot_cases      550      652      102 0.16971714
## 40  2020-02-05  tot_cases      555      657      102 0.16831683
## 41  2020-02-06  tot_cases      557      658      101 0.16625514
## 42  2020-02-07  tot_cases      562      663      101 0.16489796
## 43  2020-02-08  tot_cases      570      670      100 0.16129032
## 44  2020-02-09  tot_cases      605      705      100 0.15267176
## 45  2020-02-10  tot_cases      614      713       99 0.14920874
## 46  2020-02-11  tot_cases      625      721       96 0.14264487
## 47  2020-02-12  tot_cases      635      731       96 0.14055637
## 48  2020-02-13  tot_cases      641      736       95 0.13798112
## 49  2020-02-14  tot_cases      649      743       94 0.13505747
## 50  2020-02-15  tot_cases      654      748       94 0.13409415
## 51  2020-02-16  tot_cases      667      758       91 0.12771930
## 52  2020-02-17  tot_cases      685      776       91 0.12457221
## 53  2020-02-18  tot_cases      692      783       91 0.12338983
## 54  2020-02-19  tot_cases      709      799       90 0.11936340
## 55  2020-02-20  tot_cases      723      811       88 0.11473272
## 56  2020-02-21  tot_cases      742      829       87 0.11075748
## 57  2020-02-22  tot_cases      768      855       87 0.10720887
## 58  2020-02-23  tot_cases      792      877       85 0.10185740
## 59  2020-02-24  tot_cases      811      896       85 0.09958992
## 60  2020-02-25  tot_cases      835      920       85 0.09686610
## 61  2020-02-26  tot_cases      879      963       84 0.09120521
## 62  2020-02-27  tot_cases      916      998       82 0.08568443
## 63  2020-02-28  tot_cases      968     1049       81 0.08031730
## 64  2020-02-29  tot_cases     1005     1087       82 0.07839388
## 65  2020-03-01  tot_cases     1094     1177       83 0.07309555
## 66  2020-03-02  tot_cases     1172     1254       82 0.06760099
## 67  2020-03-03  tot_cases     1343     1424       81 0.05854716
## 68  2020-03-04  tot_cases     1482     1565       83 0.05447982
## 69  2021-07-05 new_deaths      106       37       69 0.96503497
## 70  2021-07-04 new_deaths      101       38       63 0.90647482
## 71  2021-01-18 new_deaths     2674     1130     1544 0.81177708
## 72  2021-07-03 new_deaths      142       86       56 0.49122807
## 73  2021-01-19 new_deaths     3036     4578     1542 0.40504334
## 74  2020-12-26 new_deaths     2248     3093      845 0.31642015
## 75  2020-12-24 new_deaths     3274     2463      811 0.28272616
## 76  2021-06-27 new_deaths      139      105       34 0.27868852
## 77  2021-06-26 new_deaths      175      142       33 0.20820189
## 78  2021-06-20 new_deaths      177      145       32 0.19875776
## 79  2021-06-19 new_deaths      180      154       26 0.15568862
## 80  2021-06-28 new_deaths      193      170       23 0.12672176
## 81  2021-06-24 new_deaths      287      258       29 0.10642202
## 82  2021-06-17 new_deaths      334      302       32 0.10062893
## 83  2021-06-23 new_deaths      310      281       29 0.09813875
## 84  2021-06-25 new_deaths      300      273       27 0.09424084
## 85  2021-06-22 new_deaths      283      258       25 0.09242144
## 86  2021-06-18 new_deaths      210      192       18 0.08955224
## 87  2021-06-13 new_deaths      200      184       16 0.08333333
## 88  2021-05-30 new_deaths      237      220       17 0.07439825
## 89  2020-03-21 new_deaths      114      107        7 0.06334842
## 90  2021-06-11 new_deaths      326      306       20 0.06329114
## 91  2021-06-16 new_deaths      310      293       17 0.05638474
## 92  2021-06-15 new_deaths      336      319       17 0.05190840
## 93  2020-02-02  new_cases        1      557      556 1.99283154
## 94  2021-07-05  new_cases    11586     3575     8011 1.05679045
## 95  2021-07-04  new_cases    12813     4156     8657 1.02033119
## 96  2021-07-03  new_cases    14988     5887     9101 0.87195210
## 97  2021-06-10  new_cases    16732    12363     4369 0.30032652
## 98  2021-01-18  new_cases   138860   107646    31214 0.25325144
## 99  2021-01-19  new_cases   145017   176292    31275 0.19467242
## 100 2021-07-02  new_cases    16845    14183     2662 0.17158695
## 101 2021-06-20  new_cases     9238     7787     1451 0.17045521
## 102 2020-12-24  new_cases   222830   195402    27428 0.13116165
## 103 2021-06-01  new_cases     9691     8540     1151 0.12626844
## 104 2021-01-29  new_cases   156346   139722    16624 0.11229853
## 105 2020-12-26  new_cases   151877   169350    17473 0.10878911
## 106 2021-06-30  new_cases    17308    15526     1782 0.10854602
## 107 2021-06-28  new_cases     9695     8701      994 0.10806697
## 108 2021-06-09  new_cases    19405    21526     2121 0.10363783
## 109 2021-01-09  new_cases   249814   226455    23359 0.09809162
## 110 2021-01-30  new_cases   137320   150808    13488 0.09362506
## 111 2021-07-01  new_cases    18738    17149     1589 0.08855574
## 112 2021-06-08  new_cases    14357    15667     1310 0.08726352
## 113 2021-06-29  new_cases    16174    15051     1123 0.07192954
## 114 2021-06-06  new_cases    12103    11304      799 0.06827018
## 115 2020-07-14  new_cases    65688    61818     3870 0.06070303
## 116 2021-01-08  new_cases   295299   312357    17058 0.05614361
## 117 2021-05-24  new_cases    15656    14828      828 0.05432358
## 118 2021-05-31  new_cases     9193     9700      507 0.05367067
## 119 2021-05-03  new_cases    33241    31601     1640 0.05058450
## 120 2020-07-15  new_cases    70325    73939     3614 0.05010259

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     IN tot_deaths   3407157   3378244    28913 0.008522120
## 2     SC tot_deaths   2291589   2305862    14273 0.006209093
## 3     CA tot_deaths  14183041  14129523    53518 0.003780512
## 4     NC tot_deaths   3073917   3062861    11056 0.003603194
## 5     MS tot_deaths   1998075   1991323     6752 0.003384972
## 6     KY tot_deaths   1634463   1630052     4411 0.002702392
## 7     AL tot_deaths   2743934   2738028     5906 0.002154703
## 8     RI tot_deaths    749883    751479     1596 0.002126070
## 9     NM tot_deaths   1001515    999916     1599 0.001597857
## 10    CA  tot_cases 865747767 837321729 28426038 0.033382123
## 11    AL  tot_cases 132184325 131406619   777706 0.005900855
## 12    SC  tot_cases 129358076 129977727   619651 0.004778754
## 13    RI  tot_cases  32450790  32591078   140288 0.004313775
## 14    MI  tot_cases 214132223 214386719   254496 0.001187793
## 15    MS  tot_cases  77187328  77104046    83282 0.001079542
## 16    MS new_deaths      7432      7332      100 0.013546464
## 17    NM new_deaths      4382      4344       38 0.008709603
## 18    CA new_deaths     63517     62992      525 0.008299805
## 19    AL new_deaths     11454     11360       94 0.008240554
## 20    KY new_deaths      7285      7229       56 0.007716687
## 21    NC new_deaths     13517     13434       83 0.006159326
## 22    MI new_deaths     21076     20995       81 0.003850633
## 23    IN new_deaths     13914     13863       51 0.003672103
## 24    TX new_deaths     51507     51349      158 0.003072256
## 25    TN new_deaths     12611     12576       35 0.002779211
## 26    WA new_deaths      5954      5939       15 0.002522492
## 27    RI new_deaths      2736      2730        6 0.002195390
## 28    UT new_deaths      2371      2368        3 0.001266090
## 29    CA  new_cases   3880232   3713944   166288 0.043793560
## 30    AL  new_cases    555727    552325     3402 0.006140506
## 31    VI  new_cases      3932      3916       16 0.004077472
## 32    MS  new_cases    323003    321780     1223 0.003793524
## 33    LA  new_cases    483605    482096     1509 0.003125191
## 34    NV  new_cases    335771    334763     1008 0.003006559
## 35    FL  new_cases   2344516   2337613     6903 0.002948659
## 36    WY  new_cases     62592     62445      147 0.002351304
## 37    UT  new_cases    416971    416110      861 0.002067026
## 38    KS  new_cases    319154    318515      639 0.002004175
## 39    WA  new_cases    453368    452483      885 0.001953964
## 40    AK  new_cases     68595     68478      117 0.001707120
## 41    MI  new_cases   1002081   1000375     1706 0.001703908
## 42    OR  new_cases    209377    209035      342 0.001634752
## 43    NC  new_cases   1015407   1014359     1048 0.001032631
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 33,540
## Columns: 15
## $ date           <date> 2021-02-12, 2020-07-28, 2020-08-22, 2020-10-22, 2020-0~
## $ state          <chr> "UT", "MP", "AR", "MP", "AS", "HI", "AK", "TX", "NYC", ~
## $ tot_cases      <dbl> 359641, 40, 56199, 88, 0, 661, 71521, 1867163, 948436, ~
## $ conf_cases     <dbl> 359641, 40, NA, 88, NA, NA, NA, NA, 782257, NA, 106, NA~
## $ prob_cases     <dbl> 0, 0, NA, 0, NA, NA, NA, NA, 166179, NA, 0, NA, 0, 4003~
## $ new_cases      <dbl> 1060, 0, 547, 0, 0, 8, 235, 24010, 394, 18811, 0, 0, 11~
## $ pnew_case      <dbl> 0, 0, 0, 0, 0, 0, 0, 4196, 95, 3202, 0, 0, 0, 197, 0, 0~
## $ tot_deaths     <dbl> 1785, 2, 674, 2, 0, 17, 377, 33124, 33203, 23357, 2, 0,~
## $ conf_death     <dbl> 1729, 2, NA, 2, NA, NA, NA, NA, 28130, NA, 2, NA, NA, 1~
## $ prob_death     <dbl> 56, 0, NA, 0, NA, NA, NA, NA, 5073, NA, 0, NA, NA, 350,~
## $ new_deaths     <dbl> 11, 0, 11, 0, 0, 0, 0, 345, 6, 190, 0, 0, 7, 8, 5, 0, 1~
## $ pnew_death     <dbl> 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, ~
## $ created_at     <chr> "02/13/2021 02:50:08 PM", "07/29/2020 02:34:46 PM", "08~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", "Agree", NA, "Not agree"~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", "Agree", NA, "Not agree"~
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2021-07-02 hosp_ped      662      597       65 0.10325655
## 2 2021-07-03 hosp_ped      638      597       41 0.06639676

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   523814   518483     5331 0.010229330
## 2     TN        inp   558512   559654     1142 0.002042631
## 3     NM        inp   137802   137991      189 0.001370593
## 4     NH   hosp_ped      271      361       90 0.284810127
## 5     ME   hosp_ped      452      509       57 0.118626431
## 6     KY   hosp_ped     5518     5308      210 0.038795492
## 7     MA   hosp_ped     5015     5201      186 0.036413469
## 8     AR   hosp_ped     5977     5840      137 0.023186934
## 9     TN   hosp_ped     7924     8102      178 0.022213902
## 10    DE   hosp_ped     1647     1683       36 0.021621622
## 11    AL   hosp_ped     7711     7555      156 0.020437574
## 12    WV   hosp_ped     2226     2269       43 0.019132369
## 13    KS   hosp_ped     1711     1679       32 0.018879056
## 14    NV   hosp_ped     1999     2037       38 0.018830525
## 15    AZ   hosp_ped    11435    11266      169 0.014889212
## 16    VA   hosp_ped     6604     6513       91 0.013875124
## 17    IN   hosp_ped     6913     6826       87 0.012664677
## 18    MS   hosp_ped     3727     3686       41 0.011061648
## 19    MO   hosp_ped    15406    15241      165 0.010767775
## 20    SC   hosp_ped     2706     2679       27 0.010027855
## 21    PA   hosp_ped    19857    20010      153 0.007675521
## 22    WA   hosp_ped     4288     4263       25 0.005847269
## 23    NM   hosp_ped     3125     3107       18 0.005776637
## 24    IA   hosp_ped     2275     2287       12 0.005260851
## 25    CO   hosp_ped     9355     9401       46 0.004905097
## 26    NJ   hosp_ped     9108     9142       34 0.003726027
## 27    OH   hosp_ped    25500    25406       94 0.003693081
## 28    IL   hosp_ped    19711    19644       67 0.003404904
## 29    GA   hosp_ped    21902    21973       71 0.003236467
## 30    MT   hosp_ped     1022     1025        3 0.002931119
## 31    PR   hosp_ped    11353    11380       27 0.002375401
## 32    CA   hosp_ped    30719    30667       52 0.001694197
## 33    LA   hosp_ped     3174     3179        5 0.001574059
## 34    TX   hosp_ped    38680    38739       59 0.001524174
## 35    FL   hosp_ped    54840    54921       81 0.001475934
## 36    HI   hosp_ped      720      721        1 0.001387925
## 37    NC   hosp_ped    10619    10606       13 0.001224971
## 38    AL hosp_adult   443621   439848     3773 0.008541330
## 39    TN hosp_adult   494022   494969      947 0.001915083
## 40    NM hosp_adult   112634   112842      208 0.001844986
## 41    ME hosp_adult    37173    37121       52 0.001399844
## 42    WV hosp_adult   126618   126444      174 0.001375157
## 43    KY hosp_adult   299353   299757      404 0.001348667
## 44    NH hosp_adult    39064    39014       50 0.001280771
## 45    CA hosp_adult  2422197  2425080     2883 0.001189534
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 27,682
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 7
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 15,113
## Columns: 69
## $ date                                   <date> 2021-08-03, 2021-08-03, 2021-0~
## $ MMWR_week                              <dbl> 31, 31, 31, 31, 31, 31, 31, 31,~
## $ state                                  <chr> "MH", "MN", "AL", "MD", "NC", "~
## $ Distributed                            <dbl> 51300, 6729450, 5167970, 880302~
## $ Distributed_Janssen                    <dbl> 10800, 349300, 281300, 440400, ~
## $ Distributed_Moderna                    <dbl> 40500, 2700980, 2377380, 345114~
## $ Distributed_Pfizer                     <dbl> 0, 3679170, 2509290, 4911480, 6~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 87823, 119324, 105400, 145608, ~
## $ Distributed_Per_100k_12Plus            <dbl> 102839, 140840, 123432, 170506,~
## $ Distributed_Per_100k_18Plus            <dbl> 112755, 155182, 135469, 186861,~
## $ Distributed_Per_100k_65Plus            <dbl> 518339, 731158, 608113, 917559,~
## $ vxa                                    <dbl> 36161, 6102310, 3634744, 723766~
## $ Administered_12Plus                    <dbl> 36132, 6082956, 3634417, 723724~
## $ Administered_18Plus                    <dbl> 36069, 5709218, 3515687, 675157~
## $ Administered_65Plus                    <dbl> 2101, 1599519, 1225637, 1686839~
## $ Administered_Janssen                   <dbl> 1206, 273277, 121830, 277559, 3~
## $ Administered_Moderna                   <dbl> 34955, 2359899, 1661529, 276459~
## $ Administered_Pfizer                    <dbl> 0, 3468298, 1851381, 4186640, 5~
## $ Administered_Unk_Manuf                 <dbl> 0, 836, 4, 8864, 457, 36, 565, ~
## $ Administered_Fed_LTC                   <dbl> 0, 176248, 90554, 195303, 22810~
## $ Administered_Fed_LTC_Residents         <dbl> 0, 73383, 48060, 94356, 112427,~
## $ Administered_Fed_LTC_Staff             <dbl> 0, 70268, 32757, 74670, 73173, ~
## $ Administered_Fed_LTC_Unk               <dbl> 0, 32597, 9737, 26277, 42502, 2~
## $ Administered_Fed_LTC_Dose1             <dbl> 0, 107732, 55156, 115925, 13667~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 0, 43418, 28477, 52713, 63620, ~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 0, 41574, 20542, 43429, 42856, ~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 0, 22740, 6137, 19783, 30194, 1~
## $ Admin_Per_100k                         <dbl> 61906, 108204, 74130, 119716, 9~
## $ Admin_Per_100k_12Plus                  <dbl> 72432, 127309, 86805, 140178, 1~
## $ Admin_Per_100k_18Plus                  <dbl> 79278, 131656, 92157, 143315, 1~
## $ Admin_Per_100k_65Plus                  <dbl> 21229, 173789, 144220, 175823, ~
## $ Recip_Administered                     <dbl> 36214, 6130082, 3736050, 728051~
## $ Administered_Dose1_Recip               <dbl> 19994, 3333060, 2154479, 392978~
## $ Administered_Dose1_Pop_Pct             <dbl> 34.2, 59.1, 43.9, 65.0, 51.6, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 19973, 3321978, 2154149, 392930~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 40.0, 69.5, 51.4, 76.1, 60.1, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 19925, 3123896, 2075040, 366521~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 43.8, 72.0, 54.4, 77.8, 62.5, 6~
## $ Administered_Dose1_Recip_65Plus        <dbl> 1157, 852313, 690242, 895212, 1~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 11.7, 92.6, 81.2, 93.3, 84.6, 9~
## $ vxc                                    <dbl> 17307, 3040861, 1693504, 356886~
## $ vxcpoppct                              <dbl> 29.6, 53.9, 34.5, 59.0, 43.9, 4~
## $ Series_Complete_12Plus                 <dbl> 17298, 3032831, 1693466, 356870~
## $ Series_Complete_12PlusPop_Pct          <dbl> 34.7, 63.5, 40.4, 69.1, 51.2, 5~
## $ vxcgte18                               <dbl> 17275, 2858303, 1652134, 335011~
## $ vxcgte18pct                            <dbl> 38.0, 65.9, 43.3, 71.1, 53.6, 5~
## $ vxcgte65                               <dbl> 1008, 801731, 591426, 844755, 1~
## $ vxcgte65pct                            <dbl> 10.2, 87.1, 69.6, 88.1, 77.2, 8~
## $ Series_Complete_Janssen                <dbl> 1199, 274012, 124600, 269678, 3~
## $ Series_Complete_Moderna                <dbl> 16097, 1116834, 746560, 1310927~
## $ Series_Complete_Pfizer                 <dbl> 11, 1649722, 822125, 1985705, 2~
## $ Series_Complete_Unk_Manuf              <dbl> 0, 293, 219, 2558, 53, 18, 137,~
## $ Series_Complete_Janssen_12Plus         <dbl> 1198, 273993, 124594, 269649, 3~
## $ Series_Complete_Moderna_12Plus         <dbl> 16089, 1116822, 746549, 1310893~
## $ Series_Complete_Pfizer_12Plus          <dbl> 11, 1641723, 822104, 1985603, 2~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 0, 293, 219, 2558, 53, 18, 137,~
## $ Series_Complete_Janssen_18Plus         <dbl> 1195, 273518, 124535, 269534, 3~
## $ Series_Complete_Moderna_18Plus         <dbl> 16071, 1114783, 746285, 1310577~
## $ Series_Complete_Pfizer_18Plus          <dbl> 9, 1469720, 781095, 1767515, 23~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 0, 282, 219, 2485, 52, 18, 120,~
## $ Series_Complete_Janssen_65Plus         <dbl> 65, 46101, 32206, 50551, 42106,~
## $ Series_Complete_Moderna_65Plus         <dbl> 943, 338638, 312228, 402682, 65~
## $ Series_Complete_Pfizer_65Plus          <dbl> 0, 416927, 246854, 390774, 6574~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 0, 65, 138, 748, 35, 11, 54, 0,~
## $ Series_Complete_FedLTC                 <dbl> 0, 68296, 35927, 78415, 90579, ~
## $ Series_Complete_FedLTC_Residents       <dbl> 0, 29784, 19890, 41147, 47820, ~
## $ Series_Complete_FedLTC_Staff           <dbl> 0, 28507, 12335, 30545, 29596, ~
## $ Series_Complete_FedLTC_Unknown         <dbl> 0, 10005, 3702, 6723, 13163, 14~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   8.31e+9    1.66e+8   3.51e+7 605510       32981    
## 2 after    8.27e+9    1.65e+8   3.49e+7 602741       28509    
## 3 pctchg   4.40e-3    3.97e-3   4.59e-3      0.00457     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 28,509
## Columns: 6
## $ date       <date> 2021-02-12, 2020-08-22, 2020-06-05, 2021-07-27, 2021-01-06~
## $ state      <chr> "UT", "AR", "HI", "AK", "TX", "TX", "GA", "MA", "OK", "AK",~
## $ tot_cases  <dbl> 359641, 56199, 661, 71521, 1867163, 1236648, 493, 662699, 2~
## $ tot_deaths <dbl> 1785, 674, 17, 377, 33124, 23357, 13, 17427, 102, 17, 1331,~
## $ new_cases  <dbl> 1060, 547, 8, 235, 24010, 18811, 115, 1598, 96, 29, 89, 870~
## $ new_deaths <dbl> 11, 11, 0, 0, 345, 190, 7, 8, 5, 0, 1, 15, 2, 1, 0, 0, 34, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 2.78e+7    2.19e+7 471723      27682     
## 2 after  2.77e+7    2.18e+7 459822      26679     
## 3 pctchg 5.58e-3    5.57e-3      0.0252     0.0362
## 
## 
## Processed for cdcHosp:
## Rows: 26,679
## Columns: 5
## $ date       <date> 2020-07-22, 2020-07-20, 2020-07-19, 2020-07-18, 2020-07-18~
## $ state      <chr> "IA", "IA", "ND", "IA", "ND", "TX", "OK", "CT", "ND", "NM",~
## $ inp        <dbl> 0, 1, 46, 10, 33, 12003, 678, 215, 16, 119, 51, 19, 250, 14~
## $ hosp_adult <dbl> 0, 1, NA, 10, NA, 7999, 566, 115, NA, NA, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> 0, 0, NA, 0, NA, 194, 9, 0, NA, NA, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 8.40e+10 3.47e+10 311274.    1.13e+10 575411.     3.38e+10  384223.   
## 2 after  4.00e+10 1.68e+10 263386.    5.47e+ 9 524476.     1.63e+10  329394.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.154 5.16e- 1      0.0885 5.16e- 1       0.143
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 11,883
## Columns: 9
## $ date        <date> 2021-08-03, 2021-08-03, 2021-08-03, 2021-08-03, 2021-08-0~
## $ state       <chr> "MN", "AL", "MD", "NC", "SD", "MO", "ND", "NE", "WY", "AZ"~
## $ vxa         <dbl> 6102310, 3634744, 7237660, 9776317, 854287, 5503756, 66497~
## $ vxc         <dbl> 3040861, 1693504, 3568868, 4606310, 416490, 2549091, 30623~
## $ vxcpoppct   <dbl> 53.9, 34.5, 59.0, 43.9, 47.1, 41.5, 40.2, 49.7, 36.7, 45.4~
## $ vxcgte65    <dbl> 801731, 591426, 844755, 1352070, 131441, 792717, 89800, 26~
## $ vxcgte65pct <dbl> 87.1, 69.6, 88.1, 77.2, 86.5, 74.6, 74.9, 85.7, 73.6, 74.5~
## $ vxcgte18    <dbl> 2858303, 1652134, 3350111, 4390894, 400144, 2446269, 29565~
## $ vxcgte18pct <dbl> 65.9, 43.3, 71.1, 53.6, 59.9, 51.3, 50.8, 62.6, 46.2, 55.7~
## 
## Integrated per capita data file:
## Rows: 28,722
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_210804)

The raw hospital data is explored for admissions with confirmed/suspected coronavirus:

cdcHospAdmit_210804 <- cdc_daily_210804$dfRaw$cdcHosp %>%
    select(state, date, ends_with("confirmed"), ends_with("suspected")) %>%
    filter(state %in% c(state.abb, "DC")) %>%
    arrange(date, state) %>%
    pivot_longer(-c(state, date)) %>%
    mutate(name=stringr::str_replace(name, pattern="previous_day_admission_", replacement=""), 
           name=stringr::str_replace(name, pattern="_covid", replacement="")
           ) %>%
    left_join(getStateData(keepVars=c("state", "pop")), by="state") %>%
    mutate(vpm=1000000*value/pop) %>%
    group_by(state, name) %>%
    mutate(vpm7=zoo::rollmean(vpm, k=7, fill=NA)) %>%
    ungroup()

cdcHospAdmit_210804 %>%
    filter(!is.na(vpm7), state %in% state.abb) %>%
    mutate(div=as.character(state.division)[match(state, state.abb)]) %>%
    group_by(div, date, name) %>%
    summarize(wt_vpm7=sum(pop*vpm7)/sum(pop), tot_pop=sum(pop), .groups="drop") %>%
    ggplot(aes(x=date, y=wt_vpm7)) + 
    geom_col(aes(fill=name), position="stack") + 
    facet_wrap(~div) + 
    scale_fill_discrete("Metric") + 
    labs(x=NULL, 
         y="Newly admitted for COVID per million (rolling 7-day)", 
         title="Hospital admissions for COVID", 
         subtitle="All metrics divided by total population (all ages) for states reporting"
         )

Hospital coverage data became robust about a year ago. The overwhelming majority of admissions are adult, split between confirmed and suspected cases. Next steps are to explore changes in admissions by age groups:

hospAge_210804 <- cdc_daily_210804$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_210804
## # A tibble: 498,276 x 8
##    state date       name                     value confSusp adultPed age   div  
##    <chr> <date>     <chr>                    <dbl> <chr>    <chr>    <chr> <chr>
##  1 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    0-19  <NA> 
##  2 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    20-29 <NA> 
##  3 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    30-39 <NA> 
##  4 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    40-49 <NA> 
##  5 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    50-59 <NA> 
##  6 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    60-69 <NA> 
##  7 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    70-79 <NA> 
##  8 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    80+   <NA> 
##  9 PR    2020-07-27 previous_day_admission_~    NA suspect~ adult    0-19  <NA> 
## 10 PR    2020-07-27 previous_day_admission_~    NA suspect~ adult    20-29 <NA> 
## # ... with 498,266 more rows
# Plot for overall trends by age group
p1 <- hospAge_210804 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Jul 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

# Line plots by age group
p1 + 
    geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

# Stacked bar plots by age group
p1 + 
    geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Proportions by age group
p1 + 
    geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_210804 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Jul 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

Next steps are to explore alignment of the hospitalization and case/death curves. Michigan having had a distinct spring peak is used as an example:

allHosp_210804 <- hospAge_210804 %>%
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>%
    ungroup() %>%
    left_join(getStateData(keepVars=c("state", "pop"))) %>%
    mutate(vpm7=1000000*value7/pop)
## Joining, by = "state"
allHosp_210804
## # A tibble: 83,046 x 7
##    date       state ageBucket value value7     pop  vpm7
##    <date>     <chr> <chr>     <dbl>  <dbl>   <dbl> <dbl>
##  1 2020-01-01 AL    0-19         NA     NA 4903185    NA
##  2 2020-01-01 AL    20-59        NA     NA 4903185    NA
##  3 2020-01-01 AL    60+          NA     NA 4903185    NA
##  4 2020-01-01 HI    0-19         NA     NA 1415872    NA
##  5 2020-01-01 HI    20-59        NA     NA 1415872    NA
##  6 2020-01-01 HI    60+          NA     NA 1415872    NA
##  7 2020-01-01 IN    0-19         NA     NA 6732219    NA
##  8 2020-01-01 IN    20-59        NA     NA 6732219    NA
##  9 2020-01-01 IN    60+          NA     NA 6732219    NA
## 10 2020-01-01 LA    0-19         NA     NA 4648794    NA
## # ... with 83,036 more rows
allCaseDeath_210804 <- cdc_daily_210804$dfPerCapita %>%
    select(state, date, new_cases, new_deaths, vxa, vxc, cpm7, dpm7, vxapm7, vxcpm7) %>%
    pivot_longer(-c(state, date))
allCaseDeath_210804
## # A tibble: 229,776 x 4
##    state date       name       value
##    <chr> <date>     <chr>      <dbl>
##  1 AL    2020-01-01 new_cases     NA
##  2 AL    2020-01-01 new_deaths    NA
##  3 AL    2020-01-01 vxa           NA
##  4 AL    2020-01-01 vxc           NA
##  5 AL    2020-01-01 cpm7          NA
##  6 AL    2020-01-01 dpm7          NA
##  7 AL    2020-01-01 vxapm7        NA
##  8 AL    2020-01-01 vxcpm7        NA
##  9 HI    2020-01-01 new_cases     NA
## 10 HI    2020-01-01 new_deaths    NA
## # ... with 229,766 more rows
allPivot_210804 <- allHosp_210804 %>%
    select(state, date, name=ageBucket, value=vpm7) %>%
    bind_rows(allCaseDeath_210804) %>%
    checkUniqueRows(uniqueBy=c("state", "date", "name"))
## 
## *** File has been checked for uniqueness by: state date name
allPivot_210804
## # A tibble: 312,822 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 312,812 more rows
# Plot Michigan data
typeMapper <- c("cases"="1. Cases per million per day (rolling 7 mean)", 
                "deaths"="2. Deaths per million per day (rolling 7 mean)", 
                "hosp"="3. Admitted to hospital per million per day (rolling 7 mean)", 
                "vax"="4. Vaccinated per capita (administered, completed)"
                )
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType != "notuse") %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(data=~filter(., plotType=="cases"), color="blue", size=1) +
    geom_line(data=~filter(., plotType=="deaths"), color="red", size=1) +
    geom_line(data=~filter(., plotType=="vax"), aes(color=name, group=name, y=value/1000000)) +
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name), position="stack") + 
    scale_color_discrete("Vaccine\nMetric") + 
    scale_fill_discrete("Hospitalized\nby Age") +
    facet_wrap(~typeMapper[plotType], scales="free_y") + 
    labs(x=NULL, y=NULL) +
    lims(y=c(0, NA))

hospCase <- 10
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType %in% c("cases", "hosp")) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospCase*value), position="stack") + 
    geom_line(data=~filter(., plotType=="cases"), color="black", size=1) +
    scale_fill_discrete("Hospital Admssions by Age") + 
    scale_y_continuous("Cases per million (rolling 7 mean per day)", 
                       sec.axis = sec_axis(~ . / hospCase, 
                                           name = "Hospital admissions per million (rolling 7 mean per day"
                                           )
                       ) +
    labs(x=NULL, 
         title="Alignment of Michigan cases and hospitalizations data", 
         subtitle=paste0("Ratio of ", 
                         hospCase, 
                         ":1 applied (cases are black line, hospital admissions are stacked bar)"
                         )
         ) + 
    theme(legend.position="bottom")

hospDeath <- 0.2
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType %in% c("deaths", "hosp")) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospDeath*value), position="stack") + 
    geom_line(data=~filter(., plotType=="deaths"), color="black", size=1) +
    scale_fill_discrete("Hospital Admssions by Age") + 
    scale_y_continuous("Deaths per million (rolling 7 mean per day)", 
                       sec.axis = sec_axis(~ . / hospDeath, 
                                           name = "Hospital admissions per million (rolling 7 mean per day"
                                           )
                       ) +
    labs(x=NULL, 
         title="Alignment of Michigan deaths and hospitalizations data", 
         subtitle=paste0("Ratio of ", 
                         hospDeath, 
                         ":1 applied (deaths are black line, hospital admissions are stacked bar)"
                         )
         ) + 
    theme(legend.position="bottom")

At a glance, the Michigan data appear reasonably well aligned. Hospital admissions run at ~10% of confirmed cases with a small delay. Deaths run at ~20% of hospital admissions in the mid-winter wave and ~10% of admissions in the spring wave. These are consistent with estimates of ~1.5% CFR and ~5 cases per diagnosed cases (fatality rate ~0.3%).

Next steps are to convert this process to functional form, automate selection of scaling parameters, and explore other states of interest:

# Function to create case-hospital-death file
makeCaseHospDeath <- function(dfHosp, dfCaseDeath) {

    # FUNCTION ARGUMENTS:
    # dfHosp: the tibble or data.frame containing the hospital data by date-state
    # dfCaseDeath: the tibble or data.frame containing the case and death data by date-state
    
    allHosp <- dfHosp %>%
        mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
        group_by(date, state, ageBucket) %>% 
        summarize(value=sum(value), .groups="drop") %>% 
        group_by(ageBucket, state) %>% 
        mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>%
        ungroup() %>%
        left_join(getStateData(keepVars=c("state", "pop"))) %>%
        mutate(vpm7=1000000*value7/pop)

    allCaseDeath <- dfCaseDeath %>%
        select(state, date, new_cases, new_deaths, vxa, vxc, cpm7, dpm7, vxapm7, vxcpm7) %>%
        pivot_longer(-c(state, date))

    allPivot <- allHosp %>%
        select(state, date, name=ageBucket, value=vpm7) %>%
        bind_rows(allCaseDeath) %>%
        checkUniqueRows(uniqueBy=c("state", "date", "name"))
    
    allPivot
    
}

alignCaseHospDeath <- function(dfPivot=NULL, 
                               dfHosp=NULL, 
                               dfCaseDeath=NULL, 
                               typeMapper=c("cases"="1. Cases per million per day (rolling 7 mean)", 
                                            "deaths"="2. Deaths per million per day (rolling 7 mean)", 
                                            "hosp"="3. Admitted to hospital per million per day (rolling 7 mean)", 
                                            "vax"="4. Vaccinated per capita (administered, completed)"
                                            ), 
                               keyState="MI", 
                               hospCaseScalar=10, 
                               hospDeathScalar=0.2, 
                               returnPlots=FALSE
                               ) 
    {
    
    # FUNCTION ARGUMENTS:
    # dfPivot: the tibble or data.frame containing integrated case-hospital-death data 
    #          (if NULL, build from dfHosp and dfCaseDeath)
    # dfHosp: the tibble or data.frame containing the hospital data by date-state
    # dfCaseDeath: the tibble or data.frame containing the case and death data by date-state
    # typeMapper: mapping file for labelling facets
    # keyState: the state to explore
    # hospCaseScalar: the scalar to be applied for placing cases and hospitalizations on the same plot
    # hospDeathScalar: the scalar to be applied for placing hospitalizations and deaths on the same plot
    
    # Create the pivoted data if it was not passed
    if (is.null(dfPivot)) {
        if (is.null(dfHosp) | is.null(dfCaseDeath)) stop("\nMust pass dfPivot OR both of dfHosp and dfCaseDeath\n")
        dfPivot <- makeCaseHospDeath(dfHosp=dfHosp, dfCaseDeath=dfCaseDeath)
    }

    # Create the plotting data
    plotData <- dfPivot %>%
        filter(state==keyState, !is.na(value)) %>%
        mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                                  name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                                  name=="cpm7" ~ "cases", 
                                  name=="dpm7" ~ "deaths", 
                                  TRUE ~ "notuse"
                                  )
               )
    
    # Create overall plot
    p1 <- plotData %>%
        filter(plotType != "notuse") %>%
        ggplot(aes(x=date, y=value)) + 
        geom_line(data=~filter(., plotType=="cases"), color="blue", size=1) +
        geom_line(data=~filter(., plotType=="deaths"), color="red", size=1) +
        geom_line(data=~filter(., plotType=="vax"), aes(color=name, group=name, y=value/1000000)) +
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name), position="stack") + 
        scale_color_discrete("Vaccine\nMetric") + 
        scale_fill_discrete("Hospitalized\nby Age") +
        facet_wrap(~typeMapper[plotType], scales="free_y") + 
        labs(x=NULL, y=NULL, title=paste0("Key coronavirus metrics for state: ", keyState)) +
        lims(y=c(0, NA))
    print(p1)

    p2 <- plotData %>%
        filter(plotType %in% c("cases", "hosp")) %>%
        ggplot(aes(x=date, y=value)) + 
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospCaseScalar*value), position="stack") + 
        geom_line(data=~filter(., plotType=="cases"), color="black", size=1) +
        scale_fill_discrete("Hospital Admssions by Age") + 
        scale_y_continuous("Cases per million (rolling 7 mean per day)", 
                           sec.axis = sec_axis(~ . / hospCaseScalar, 
                                               name = "Hospital admissions per million (rolling 7 mean per day"
                                               )
                           ) +
        labs(x=NULL, 
             title=paste0("Alignment of ", keyState, " cases and hospitalizations data"), 
             subtitle=paste0("Ratio of ", 
                             hospCaseScalar, 
                             ":1 applied (cases are black line, hospital admissions are stacked bar)"
                             )
             ) + 
        theme(legend.position="bottom")
    print(p2)

    p3 <- plotData %>%
        filter(plotType %in% c("deaths", "hosp")) %>%
        ggplot(aes(x=date, y=value)) + 
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospDeathScalar*value), position="stack") + 
        geom_line(data=~filter(., plotType=="deaths"), color="black", size=1) +
        scale_fill_discrete("Hospital Admssions by Age") + 
        scale_y_continuous("Deaths per million (rolling 7 mean per day)", 
                           sec.axis = sec_axis(~ . / hospDeathScalar, 
                                               name = "Hospital admissions per million (rolling 7 mean per day"
                                               )
                           ) +
        labs(x=NULL, 
             title=paste0("Alignment of ", keyState, " deaths and hospitalizations data"), 
             subtitle=paste0("Ratio of ", 
                             hospDeathScalar, 
                             ":1 applied (deaths are black line, hospital admissions are stacked bar)"
                             )
             ) + 
        theme(legend.position="bottom")
    print(p3)
    
    if(isTRUE(returnPlots)) list(p1=p1, p2=p2, p3=p3)
    
}

The function is tested for MI, FL, and TX:

dfPivot_210804 <- makeCaseHospDeath(dfHosp=hospAge_210804, dfCaseDeath=cdc_daily_210804$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_210804
## # A tibble: 312,822 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 312,812 more rows
miAlign <- alignCaseHospDeath(dfPivot_210804, keyState="MI", returnPlots=TRUE)

flAlign <- alignCaseHospDeath(dfPivot_210804, keyState="FL", returnPlots=TRUE, hospDeathScalar=0.14)

txAlign <- alignCaseHospDeath(dfPivot_210804, keyState="TX", returnPlots=TRUE, hospDeathScalar=0.14)

# Key plots on a single page
gridExtra::grid.arrange(miAlign$p1, flAlign$p1, txAlign$p1, nrow=2)

gridExtra::grid.arrange(miAlign$p2, flAlign$p2, txAlign$p2, nrow=1)

gridExtra::grid.arrange(miAlign$p3, flAlign$p3, txAlign$p3, nrow=1)

Next, an implied CFR (deaths per case) rate is calculated for inclusion:

# Filter to single-state data
miData <- dfPivot_210804 %>%
    filter(state=="MI", name %in% c("cpm7", "dpm7"), !is.na(value))

# Plot core metrics
miData %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(aes(group=name, color=name)) + 
    facet_wrap(~c("cpm7"="Cases per million", "dpm7"="Deaths per million")[name], scales="free_y") + 
    labs(x=NULL, y="Value per million (rolling 7-day mean)", title="Coronavirus burden in state: MI") + 
    theme(legend.position="none")

# Create correlation for assigned lag/lead and variables in a data frame
lagCorrCheck <- function(df, lagLead=0, varFix="dpm7", varMove="cpm7") {
    df %>%
        mutate(lagVar=if(lagLead >= 0) lag(get(varMove), lagLead) else lead(get(varMove), abs(lagLead))) %>%
        filter(!is.na(lagVar)) %>%
        summarize(correl=cor(lagVar, get(varFix))) %>%
        pull(correl)
}

miCorrDF <- miData %>%
    select(date, name, value) %>%
    pivot_wider(date)
miCorrDF
## # A tibble: 553 x 3
##    date        cpm7  dpm7
##    <date>     <dbl> <dbl>
##  1 2020-01-25     0     0
##  2 2020-01-26     0     0
##  3 2020-01-27     0     0
##  4 2020-01-28     0     0
##  5 2020-01-29     0     0
##  6 2020-01-30     0     0
##  7 2020-01-31     0     0
##  8 2020-02-01     0     0
##  9 2020-02-02     0     0
## 10 2020-02-03     0     0
## # ... with 543 more rows
# Assessing best lag/lead for full dataset
lagLeads=-10:40
miRhoFull <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, FUN=function(x) lagCorrCheck(miCorrDF, lagLead=x))
                            )
bestFull <- miRhoFull %>% filter(rho==max(rho))
miRhoFull %>% 
    ggplot(aes(x=lagLead, y=rho)) + 
    geom_point() + 
    geom_hline(data=bestFull, aes(yintercept=rho), lty=2) +
    geom_vline(data=bestFull, aes(xintercept=lagLead), lty=2) +
    labs(x="Lag or lead of cases", 
         y="Correlation to deaths", 
         title="All Michigan case and death data", 
         subtitle=paste0("Best correlation ", 
                         round(bestFull$rho, 3), 
                         " obtained at lag/lead of: ", 
                         bestFull$lagLead
                         )
         )

# Assessing best lag/lead for August 2020 and beyond
lagLeads=-10:40
miRhoLate <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, 
                                       FUN=function(x) lagCorrCheck(miCorrDF %>% filter(date >= "2020-08-01"), 
                                                                    lagLead=x
                                                                    )
                                       )
                            )
bestLate <- miRhoLate %>% filter(rho==max(rho))
miRhoLate %>% 
    ggplot(aes(x=lagLead, y=rho)) + 
    geom_point() + 
    geom_hline(data=bestLate, aes(yintercept=rho), lty=2) +
    geom_vline(data=bestLate, aes(xintercept=lagLead), lty=2) +
    labs(x="Lag or lead of cases", 
         y="Correlation to deaths", 
         title="Michigan case and death data (August 2020 to present)", 
         subtitle=paste0("Best correlation ", 
                         round(bestLate$rho, 3), 
                         " obtained at lag/lead of: ", 
                         bestLate$lagLead
                         )
         )

miCorrDF %>%
    mutate(lag20=lag(cpm7, 20)) %>%
    filter(!is.na(lag20), lag20 > 0) %>%
    ggplot(aes(x=date)) + 
    geom_line(aes(y=cpm7), color="navy") + 
    geom_line(aes(y=lag20), color="navy", lty=2) + 
    geom_line(aes(y=8000*pmin(0.1, dpm7/lag20)), color="red") + 
    scale_y_continuous("Cases per million (rolling 7 mean per day) - actual and 20-day lag", 
                       sec.axis = sec_axis(~ . / 8000, 
                                           name = "Implied CFR (capped at 10%)"
                                           )
                       ) +
    labs(x=NULL, title="Implied case fatality rate using 20-day lag in Michigan")

miCorrDF %>%
    mutate(lag20=lag(cpm7, 20)) %>%
    filter(!is.na(lag20)) %>%
    ggplot(aes(x=date)) + 
    geom_line(aes(y=cpm7), color="navy") + 
    geom_line(aes(y=lag20), color="navy", lty=2) + 
    geom_line(aes(y=50*dpm7), color="red") + 
    labs(x=NULL, 
         y="Per million (7-day rolling mean)\nCases, Lag-20 cases, and 50*Deaths", 
         title="Burden metrics for Michigan"
         )

Michigan appears to fairly consistently have a lag of 2-3 weeks between cases and deaths. The CFR during spikes has consistently declined from over 10% to around 2% to around 1%. The estimated CFR outside of spikes appears noisy. Next steps are to convert to functional form and run for other states:

# Create correlation for assigned lag/lead and variables in a data frame
lagCorrCheck <- function(df, lagLead=0, varFix="dpm7", varMove="cpm7") {
    df %>%
        mutate(lagVar=if(lagLead >= 0) lag(get(varMove), lagLead) else lead(get(varMove), abs(lagLead))) %>%
        filter(!is.na(lagVar)) %>%
        summarize(correl=cor(lagVar, get(varFix))) %>%
        pull(correl)
}


findCorrAlign <- function(df, 
                          keyState, 
                          varFix="dpm7", 
                          varMove="cpm7", 
                          lagLeads=-10:40,
                          minDate=NULL, 
                          maxDate=NULL,
                          varMapper=c("cpm7"="Cases per million", "dpm7"="Deaths per million"), 
                          yLab="Value per million (rolling 7-day mean)", 
                          printPlots=TRUE, 
                          returnPlots=FALSE,
                          returnData=FALSE
                          ) {
    
    # FUNCTION ARGUMENTS
    # df: pivoted data frame with state-date-name-value
    # keyState: state to include
    # varFix: metric to be held constant
    # varMove: metric to be lagged/led
    # lagLeads: lags and leads for the variable that moves
    # minDate: minimum date for lag/lead (NULL means data-driven)
    # maxDate: maximum date for lag/lead (NULL means data-driven)
    # varMapper: mapping file for varFix and varMove to descriptive labels
    # yLab: label for the y-axis in the first plot
    # printPlots: boolean, should the plots be printed?
    # returnPlots: boolean, should the plots be returned?
    # returnData: boolean, should the data frames be returned as a list?
    
    # Set minDate and maxDate to the actual minmax if passed as NULL 
    if (is.null(minDate)) minDate <- df %>% summarize(date=min(date)) %>% pull(date)
    if (is.null(maxDate)) maxDate <- df %>% summarize(date=max(date)) %>% pull(date)
    
    # Filter to relevant data
    df <- df %>%
        filter(state %in% all_of(keyState), name %in% all_of(c(varFix, varMove)), !is.na(value))

    # Plot core metrics for requested states
    p1 <- df %>%
        ggplot(aes(x=date, y=value)) + 
        geom_line(aes(group=name, color=name)) + 
        facet_wrap(~varMapper[name], scales="free_y") + 
        labs(x=NULL, y=yLab, title=paste0("Metrics by state for: ", paste0(keyState, collapse=", "))) + 
        theme(legend.position="none")
    if(isTRUE(printPlots)) print(p1)

    # Create dataset for correlations
    dfCorr <- df %>%
        select(date, name, value) %>%
        pivot_wider(date)

    # Find correlation by lag/lead for dataset
    dfRho <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, 
                                       FUN=function(x) {
                                           lagCorrCheck(dfCorr %>% filter(date >= minDate, date <= maxDate), 
                                                        lagLead=x
                                                        )
                                           }
                                       )
                            )
    
    # Find best correlation and lag/lead
    bestRho <- dfRho %>% 
        filter(rho==max(rho))

    # Plot correlations by lag/lead
    p2 <- dfRho %>% 
        ggplot(aes(x=lagLead, y=rho)) + 
        geom_point() + 
        geom_hline(data=bestRho, aes(yintercept=rho), lty=2) +
        geom_vline(data=bestRho, aes(xintercept=lagLead), lty=2) +
        labs(x=paste0("Lag or lead of ", varMapper[varMove]), 
             y=paste0("Correlation to ", varMapper[varFix]), 
             title=paste0("Correlations by lag/lead for state: ", keyState), 
             subtitle=paste0("Best correlation ", 
                             round(bestRho$rho, 3), 
                             " obtained at lag/lead of: ", 
                             bestRho$lagLead
                             )
             )
    if(isTRUE(printPlots)) print(p2)

    if (isTRUE(returnData) | isTRUE(returnPlots)) {
        list(dfRho=if(isTRUE(returnData)) dfRho else NULL, 
             bestRho=if(isTRUE(returnData)) bestRho else NULL, 
             dfCorr=if(isTRUE(returnData)) dfCorr else NULL, 
             p1=if(isTRUE(returnPlots)) p1 else NULL, 
             p2=if(isTRUE(returnPlots)) p2 else NULL
             )
    }
    
}

findCorrAlign(dfPivot_210804, keyState="MI")

findCorrAlign(dfPivot_210804, keyState="MI", minDate="2020-08-01", returnData=TRUE)

## $dfRho
## # A tibble: 51 x 2
##    lagLead   rho
##      <int> <dbl>
##  1     -10 0.320
##  2      -9 0.348
##  3      -8 0.376
##  4      -7 0.404
##  5      -6 0.432
##  6      -5 0.460
##  7      -4 0.488
##  8      -3 0.515
##  9      -2 0.543
## 10      -1 0.570
## # ... with 41 more rows
## 
## $bestRho
## # A tibble: 1 x 2
##   lagLead   rho
##     <int> <dbl>
## 1      20 0.880
## 
## $dfCorr
## # A tibble: 553 x 3
##    date        cpm7  dpm7
##    <date>     <dbl> <dbl>
##  1 2020-01-25     0     0
##  2 2020-01-26     0     0
##  3 2020-01-27     0     0
##  4 2020-01-28     0     0
##  5 2020-01-29     0     0
##  6 2020-01-30     0     0
##  7 2020-01-31     0     0
##  8 2020-02-01     0     0
##  9 2020-02-02     0     0
## 10 2020-02-03     0     0
## # ... with 543 more rows
## 
## $p1
## NULL
## 
## $p2
## NULL
findCorrAlign(dfPivot_210804, keyState="FL")

findCorrAlign(dfPivot_210804, keyState="TX", minDate="2020-10-01")

Next steps are to create functional form for calculating IFR and aligning plots:

plotCFRLag <- function(lst, 
                       lagUse=NULL, 
                       scaleUse=NULL, 
                       cfrCap=0.06, 
                       multDeath=50,
                       mainTitle="Coronavirus data for selected geography: ", 
                       printPlots=TRUE, 
                       returnPlots=FALSE
                       ) {
    
    # FUNCTION ARGUMENTS:
    # lst: data frame with date-cpm7-dpm7 OR list with both dfCorr and bestRho
    # lagUse: the lag to use (if NULL, use the value in bestRho$lagLead)
    # scaleUse: scalar for secondary y-axis (NULL means calculate from data)
    # cfrCap: the cap for all values of CFR
    # multDeath: multiplier for death data in plot 2
    # mainTitle: main title for plots
    # printPlots: boolean, should the plots be printed?
    # returnPlots: boolean, should the plots be returned?
    
    # Create dfCorr and lagUse
    if ("list" %in% class(lst)) {
        dfCorr <- lst[["dfCorr"]]
        if (is.null(lagUse)) lagUse <- lst[["bestRho"]]$lagLead
    } else {
        dfCorr <- lst
    }
    
    # Check that dfCorr is a data frame with date-cpm7-dpm7 and lagUse is not NULL
    if (!("data.frame" %in% class(dfCorr))) stop("\nMust have a data frame for lst/dfCorr\n")
    if (!(all(c("date", "cpm7", "dpm7") %in% names(dfCorr)))) stop("\ndfCorr must have date-cpm7-dpm7\n")
    if (is.null(lagUse)) stop("\nMust have a value for lagUse\n")
    
    # Create scaleUse if not passed
    if (is.null(scaleUse)) scaleUse <- 500*ceiling(max(dfCorr$cpm7)/cfrCap/500)
    
    # Create plot of CFR by date, showing lagged cases
    basePlot <- dfCorr %>%
        mutate(lagData=if(lagUse >= 0) lag(cpm7, lagUse) else lead(cpm7, -lagUse)) %>%
        filter(!is.na(lagData), lagData > 0) %>%
        ggplot(aes(x=date)) + 
        geom_line(aes(y=cpm7), color="navy") + 
        geom_line(aes(y=lagData), color="navy", lty=2)
    p1 <- basePlot + 
        geom_line(aes(y=scaleUse*pmin(cfrCap, dpm7/lagData)), color="red") + 
        scale_y_continuous(paste0("Cases per million\n(rolling 7-day mean)"), 
                           sec.axis = sec_axis(~ . / scaleUse, 
                                               name = paste0("Implied CFR (capped at ", 
                                                             round(100*cfrCap, 1), 
                                                             "%)"
                                                             )
                                               )
                           ) +
        labs(x=NULL, 
             title=mainTitle, 
             subtitle=paste0("Red line (right axis) is implied fatality rate\n", 
                             "Blue line is cases with and without ", 
                             abs(lagUse), 
                             "-day ", 
                             if(lagUse > 0) "lag" else "lead"
                             )
             )
    if (isTRUE(printPlots)) print(p1)
    
    # Apply a CFR to the data and show alignment
    p2 <- basePlot +
        geom_line(aes(y=multDeath*dpm7), color="red") + 
        labs(x=NULL, 
             y="Per million (7-day rolling mean)", 
             title=mainTitle, 
             subtitle=paste0("Red line is ", 
                             multDeath, 
                             "*deaths\n", 
                             "Blue line is cases with and without ", 
                             abs(lagUse), 
                             "-day ", 
                             if(lagUse > 0) "lag" else "lead"
                             )
         )
    if (isTRUE(printPlots))print(p2)
    
    if (isTRUE(returnPlots)) list(p1=p1, p2=p2)
    
}

# Run for Michigan, Florida, California
findCorrAlign(dfPivot_210804, keyState="MI", minDate="2020-08-01", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "MI"))

findCorrAlign(dfPivot_210804, keyState="FL", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "FL"), multDeath=100)

findCorrAlign(dfPivot_210804, keyState="CA", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "CA"), multDeath=70)

Functions have been updated so that plots can be returned and/or printed. A new function allows for creating all plots for state on a single page:

# Function to plot all states on the same page
onePageCFRPlot <- function(df, keyState, multDeath=100, cfrCap=0.06, ...) {
    
    # FUNCTION ARGUMENTS:
    # df: the data frame containing state-date-name-value
    # keyState: the key state to be analyzed
    # multDeath: multiplier for death in the death/lagged cases chart of plotCFRLag()
    # ...: other arguments to be passed to findCorrAlign()
    
    # Find the correlations data
    corrData <- findCorrAlign(df, 
                              keyState=keyState, 
                              yLab="Value per million\n(rolling 7-day mean)", 
                              printPlots=FALSE, 
                              returnPlots=TRUE, 
                              returnData=TRUE, 
                              ...
                              )
    
    # Find CFR
    cfrData <- plotCFRLag(corrData, 
                          cfrCap=cfrCap, 
                          multDeath=multDeath, 
                          mainTitle=paste0(formals(plotCFRLag)$mainTitle, keyState), 
                          printPlots=FALSE, 
                          returnPlots=TRUE
                          )
    
    # Create single-page summary
    gridExtra::grid.arrange(corrData$p1, corrData$p2, cfrData$p1, cfrData$p2, nrow=2)
    
}

# Run for Michigan, Florida, California, Texas, New York, South Dakota
onePageCFRPlot(dfPivot_210804, keyState="MI", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210804, keyState="FL", multDeath=100)

onePageCFRPlot(dfPivot_210804, keyState="CA", multDeath=70)

onePageCFRPlot(dfPivot_210804, keyState="TX", multDeath=70)

onePageCFRPlot(dfPivot_210804, keyState="NY", multDeath=10, cfrCap=0.1)

onePageCFRPlot(dfPivot_210804, keyState="SD", multDeath=70)

Summaries are created for vaccination status by age cohort and state:

cdc_daily_210815 <- readFromRDS("cdc_daily_210815")

# Example using hard coding and wide data
cdc_daily_210815$dfRaw$vax %>% 
    filter(date==max(date), state %in% c(state.abb, "DC")) %>% 
    select(state, contains("Administered_Dose1")) %>% 
    ggplot(aes(x=fct_reorder(state, Administered_Dose1_Recip_65PlusPop_Pct))) + 
    geom_col(aes(fill="65+", y=Administered_Dose1_Recip_65PlusPop_Pct)) + 
    geom_col(aes(y=Administered_Dose1_Recip_18PlusPop_Pct, fill="18+")) + 
    geom_col(aes(y=Administered_Dose1_Pop_Pct, fill="All")) + 
    geom_text(aes(y=Administered_Dose1_Recip_65PlusPop_Pct, 
                  label=paste0(Administered_Dose1_Recip_65PlusPop_Pct, "% (", state, ")")
                  ), 
              hjust=0, 
              size=3
              ) + 
    geom_text(aes(y=Administered_Dose1_Recip_18PlusPop_Pct+0.5, 
                  label=paste0(Administered_Dose1_Recip_18PlusPop_Pct, "%")
                  ), 
              hjust=0, 
              size=3
              ) + 
    coord_flip() + 
    labs(x=NULL, 
         y="% Fully Vaccinated", 
         title="First-dose vaccinated by age cohort and state (mid-Aug 2020)", 
         subtitle="Black: all population, Yellow: 18+, Blue: 65+"
         ) + 
    scale_fill_manual("Cohort", 
                      breaks=c("All", "18+", "65+"), 
                      values=c("65+"="lightblue", "18+"="yellow", "All"="black" )
                      ) + 
    geom_text(aes(y=Administered_Dose1_Pop_Pct+0.5, 
                  label=paste0(Administered_Dose1_Pop_Pct, "%")
                  ), 
              hjust=0, 
              size=3
              ) + 
    theme(legend.position="bottom")

# Function for reproducibility
tempStackPlot <- function(df, 
                          yVars, 
                          xVar="state", 
                          yLab="", 
                          plotTitle="", 
                          colorVector=c("lightblue", "grey", "orange", "black")
                          ) {

    # FUNCTION ARGUMENTS:
    # df: data frame or tibble
    # yVars: named vector with c("variable"="name")
    # xVar: the x variable
    # yLab: the y-axis label for the plot
    # plotTitle: the title for the plot
    # colorVector: colors to use for filled bars (sequentially, can have more, but not less, than length(yVars))
    
    colorVector <- colorVector[1:length(yVars)]
    names(colorVector) <- names(yVars)
    
    p1 <- df %>% 
        select(all_of(xVar), all_of(names(yVars))) %>%
        pivot_longer(-c(all_of(xVar))) %>%
        ggplot(aes(x=fct_reorder(get(xVar[1]), value, max))) + 
        coord_flip() + 
        labs(x=NULL, y=yLab, title=plotTitle) + 
        geom_col(aes(y=value, fill=name), position="identity") + 
        geom_text(aes(y=value+0.5, 
                      label=paste0(value, "%", ifelse(name==names(yVars)[1], paste0(" (", state, ")"), ""))
                      ), 
                  hjust=0, 
                  size=3
                  ) + 
        scale_fill_manual("Cohort", 
                          breaks=rev(names(yVars)), 
                          labels=rev(unname(yVars)),
                          values=colorVector
                          ) +
        theme(legend.position="bottom")

    p1
    
}

# Run for fully vaccinated
tempStackPlot(cdc_daily_210815$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("vxcgte65pct"="65+", 
                      "vxcgte18pct"="18+", 
                      "vxcpoppct"="All"
                      ), 
              yLab="% Fully vaccinated", 
              plotTitle="Fully vaccinated by age cohort and state (mid-Aug 2020)"
              )

# Run for first dose
tempStackPlot(cdc_daily_210815$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                      "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                      "Administered_Dose1_Pop_Pct"="All"
                      ), 
              yLab="% Receiving First Dose", 
              plotTitle="First-dose vaccinated by age cohort and state (mid-Aug 2020)"
              )

The plotting is extended to show the evolution of vaccination over time:

# Create data
cdcVaxGrowth <- cdc_daily_210815$dfRaw$vax %>% 
    filter(date %in% c(as.Date(max(date)-lubridate::dmonths(c(0, 2, 4)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for fuly vaccinated
p1 <- cdcVaxGrowth %>%
    select(state, date, vxcpoppct) %>%
    pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% Fully Vaccinated (all population)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, vxcgte65pct) %>%
    pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% Fully Vaccinated (65+)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

# Run for first dose
p1 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Pop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (all population)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (65+)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

Similar plots are created for the evolution of cases per thousand and deaths per milion:

# Updated function for reproducibility
tempStackPlot <- function(df, 
                          yVars, 
                          xVar="state", 
                          yLab=NULL, 
                          plotTitle=NULL, 
                          colorVector=c("lightblue", "grey", "orange", "black"), 
                          addSuffix="%", 
                          scaleName="Cohort", 
                          textBuffer=0.5, 
                          makeDotPlot=FALSE, 
                          yLims=NULL
                          ) {

    # FUNCTION ARGUMENTS:
    # df: data frame or tibble
    # yVars: named vector with c("variable"="name"), in the desired order from right-most to left-most
    # xVar: the x variable
    # yLab: the y-axis label for the plot
    # plotTitle: the title for the plot
    # colorVector: colors to use for filled bars (sequentially, can have more, but not less, than length(yVars))
    # addSuffix: value to be appended to all values in plots (e.g., 96 would show as 96% in the text label)
    # scaleName: the name to use for the legend
    # textBuffer: distance from bar to text
    # makeDotPlot: boolean, should a dot-plot be made rather than stacked bars?
    # yLims: the limits for the y-axis passed as a length-2 vector such as c(0, 100) or c(0, NA)
    
    colorVector <- colorVector[1:length(yVars)]
    names(colorVector) <- names(yVars)
    
    # Function for the legend
    fnLegendKey <- if(isTRUE(makeDotPlot)) scale_color_manual else scale_fill_manual
    
    p1 <- df %>% 
        select(all_of(xVar), all_of(names(yVars))) %>%
        pivot_longer(-c(all_of(xVar))) %>%
        ggplot(aes(x=fct_reorder(get(xVar[1]), value, max))) + 
        coord_flip() + 
        labs(x=NULL, y=yLab, title=plotTitle) +
        (if(isTRUE(makeDotPlot)) geom_point(aes(y=value, color=name)) 
         else geom_col(aes(y=value, fill=name), position="identity")
         ) +
        geom_text(aes(y=value+textBuffer, 
                      label=paste0(value, 
                                   addSuffix, 
                                   ifelse(name==names(yVars)[1], paste0(" (", get(xVar[1]), ")"), "")
                                   )
                      ), 
                  hjust=0, 
                  size=3
                  ) + 
        fnLegendKey(scaleName, 
                    breaks=rev(names(yVars)), 
                    labels=rev(unname(yVars)),
                    values=colorVector
                    ) +
        theme(legend.position="bottom")
    
    # Add the y-limits if appropriate
    if (!is.null(yLims)) p1 <- p1 + lims(y=yLims)
    
    p1
    
}


# Create data
cdcBurdenGrowth <- cdc_daily_210815$dfPerCapita %>% 
    filter(date %in% c(as.Date(max(date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for cases
p1 <- cdcBurdenGrowth %>%
    select(state, date, tcpm) %>% 
    mutate(tcpm=round(tcpm/1000)) %>%
    pivot_wider(state, names_from="date", values_from="tcpm") %>%
    tempStackPlot(yVars=c("2021-08-13"="2021-08-13", 
                          "2021-02-11"="2021-02-11", 
                          "2020-08-12"="2020-08-12"
                          ), 
                  yLab="Cumulative cases per thousand", 
                  plotTitle="Evolution of cumulative cases per thousand by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

# Run for deaths
p2 <- cdcBurdenGrowth %>%
    select(state, date, tdpm) %>% 
    mutate(tdpm=round(tdpm)) %>%
    pivot_wider(state, names_from="date", values_from="tdpm") %>%
    tempStackPlot(yVars=c("2021-08-13"="2021-08-13", 
                          "2021-02-11"="2021-02-11", 
                          "2020-08-12"="2020-08-12"
                          ), 
                  yLab="Cumulative deaths per million", 
                  plotTitle="Evolution of cumulative deaths per million by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The latest data as of August 31 are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210902.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210902.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210902.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210804")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210804")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210804")$dfRaw$vax
                    )

cdc_daily_210902 <- readRunCDCDaily(thruLabel="Sep 1, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths        0      143      143 2.00000000
## 2   2020-02-03 tot_deaths      178      143       35 0.21806854
## 3   2020-02-04 tot_deaths      178      143       35 0.21806854
## 4   2020-02-05 tot_deaths      178      143       35 0.21806854
## 5   2020-02-06 tot_deaths      178      143       35 0.21806854
## 6   2020-02-07 tot_deaths      178      143       35 0.21806854
## 7   2020-02-08 tot_deaths      179      144       35 0.21671827
## 8   2020-02-09 tot_deaths      179      144       35 0.21671827
## 9   2020-02-10 tot_deaths      179      144       35 0.21671827
## 10  2020-02-11 tot_deaths      179      144       35 0.21671827
## 11  2020-02-12 tot_deaths      179      144       35 0.21671827
## 12  2020-02-13 tot_deaths      179      144       35 0.21671827
## 13  2020-02-14 tot_deaths      179      144       35 0.21671827
## 14  2020-02-15 tot_deaths      179      144       35 0.21671827
## 15  2020-02-16 tot_deaths      179      144       35 0.21671827
## 16  2020-02-17 tot_deaths      179      144       35 0.21671827
## 17  2020-02-18 tot_deaths      179      144       35 0.21671827
## 18  2020-02-19 tot_deaths      180      145       35 0.21538462
## 19  2020-02-20 tot_deaths      180      145       35 0.21538462
## 20  2020-02-21 tot_deaths      180      145       35 0.21538462
## 21  2020-02-22 tot_deaths      180      145       35 0.21538462
## 22  2020-02-23 tot_deaths      180      145       35 0.21538462
## 23  2020-02-24 tot_deaths      180      145       35 0.21538462
## 24  2020-02-25 tot_deaths      180      145       35 0.21538462
## 25  2020-02-26 tot_deaths      180      145       35 0.21538462
## 26  2020-02-27 tot_deaths      181      146       35 0.21406728
## 27  2020-02-28 tot_deaths      181      146       35 0.21406728
## 28  2020-02-29 tot_deaths      182      147       35 0.21276596
## 29  2020-03-01 tot_deaths      182      147       35 0.21276596
## 30  2020-03-02 tot_deaths      188      153       35 0.20527859
## 31  2020-03-06 tot_deaths      200      163       37 0.20385675
## 32  2020-03-05 tot_deaths      196      160       36 0.20224719
## 33  2020-03-03 tot_deaths      191      156       35 0.20172911
## 34  2020-03-04 tot_deaths      193      158       35 0.19943020
## 35  2020-03-07 tot_deaths      205      168       37 0.19839142
## 36  2020-03-08 tot_deaths      210      173       37 0.19321149
## 37  2020-03-10 tot_deaths      220      184       36 0.17821782
## 38  2020-03-09 tot_deaths      214      179       35 0.17811705
## 39  2020-03-11 tot_deaths      234      198       36 0.16666667
## 40  2020-03-12 tot_deaths      241      205       36 0.16143498
## 41  2020-03-13 tot_deaths      252      216       36 0.15384615
## 42  2020-03-14 tot_deaths      266      229       37 0.14949495
## 43  2020-03-15 tot_deaths      286      249       37 0.13831776
## 44  2020-03-16 tot_deaths      307      271       36 0.12456747
## 45  2020-03-17 tot_deaths      339      301       38 0.11875000
## 46  2020-03-18 tot_deaths      410      373       37 0.09450830
## 47  2020-03-20 tot_deaths      577      530       47 0.08491418
## 48  2020-03-19 tot_deaths      475      437       38 0.08333333
## 49  2020-03-21 tot_deaths      692      644       48 0.07185629
## 50  2020-03-22 tot_deaths      827      775       52 0.06491885
## 51  2020-03-25 tot_deaths     1544     1459       85 0.05661006
## 52  2020-03-24 tot_deaths     1232     1165       67 0.05590321
## 53  2020-03-23 tot_deaths      998      946       52 0.05349794
## 54  2020-03-26 tot_deaths     1897     1804       93 0.05025669
## 55  2020-02-02  tot_cases       56      510      454 1.60424028
## 56  2021-07-25 new_deaths      261      136      125 0.62972292
## 57  2021-07-24 new_deaths      287      162      125 0.55679287
## 58  2021-07-18 new_deaths      166       96       70 0.53435115
## 59  2021-07-23 new_deaths      388      226      162 0.52768730
## 60  2021-08-01 new_deaths      363      240      123 0.40796020
## 61  2021-07-26 new_deaths      368      245      123 0.40130506
## 62  2021-06-08 new_deaths      313      209      104 0.39846743
## 63  2021-06-07 new_deaths      339      500      161 0.38379023
## 64  2020-11-11 new_deaths     1516     1046      470 0.36690086
## 65  2021-07-31 new_deaths      397      274      123 0.36661699
## 66  2021-07-17 new_deaths      196      138       58 0.34730539
## 67  2021-07-19 new_deaths      256      185       71 0.32199546
## 68  2020-11-12 new_deaths     1366     1863      497 0.30783524
## 69  2020-11-10 new_deaths     1310     1761      451 0.29371540
## 70  2021-08-02 new_deaths      523      392      131 0.28633880
## 71  2021-07-05 new_deaths      141      106       35 0.28340081
## 72  2021-07-04 new_deaths      131      101       30 0.25862069
## 73  2021-06-17 new_deaths      268      334       66 0.21926910
## 74  2021-07-28 new_deaths      443      356       87 0.21777222
## 75  2021-07-29 new_deaths      460      370       90 0.21686747
## 76  2021-05-31 new_deaths      268      218       50 0.20576132
## 77  2020-09-30 new_deaths      537      660      123 0.20551378
## 78  2021-07-12 new_deaths      227      186       41 0.19854722
## 79  2021-06-13 new_deaths      167      200       33 0.17983651
## 80  2020-10-11 new_deaths      565      675      110 0.17741935
## 81  2021-06-21 new_deaths      265      315       50 0.17241379
## 82  2021-07-15 new_deaths      298      251       47 0.17122040
## 83  2020-07-13 new_deaths      869      732      137 0.17114304
## 84  2021-07-11 new_deaths      140      118       22 0.17054264
## 85  2021-07-10 new_deaths      153      129       24 0.17021277
## 86  2021-07-27 new_deaths      464      393       71 0.16569428
## 87  2020-10-08 new_deaths      681      803      122 0.16442049
## 88  2021-06-14 new_deaths      221      260       39 0.16216216
## 89  2021-07-20 new_deaths      316      269       47 0.16068376
## 90  2021-07-06 new_deaths      203      173       30 0.15957447
## 91  2021-06-01 new_deaths      334      391       57 0.15724138
## 92  2020-09-24 new_deaths      694      812      118 0.15670651
## 93  2020-07-26 new_deaths      937      802      135 0.15526164
## 94  2020-09-07 new_deaths      557      477       80 0.15473888
## 95  2021-07-22 new_deaths      331      386       55 0.15341702
## 96  2020-08-02 new_deaths      919      789      130 0.15222482
## 97  2020-09-23 new_deaths      812      944      132 0.15034169
## 98  2020-08-30 new_deaths      638      552       86 0.14453782
## 99  2021-04-11 new_deaths      428      371       57 0.14267835
## 100 2021-07-16 new_deaths      301      261       40 0.14234875
## 101 2020-09-10 new_deaths      789      908      119 0.14024750
## 102 2021-07-09 new_deaths      268      233       35 0.13972056
## 103 2020-07-12 new_deaths      865      753      112 0.13844252
## 104 2020-09-13 new_deaths      713      623       90 0.13473054
## 105 2021-06-19 new_deaths      206      180       26 0.13471503
## 106 2021-05-29 new_deaths      351      307       44 0.13373860
## 107 2020-10-15 new_deaths      693      792       99 0.13333333
## 108 2020-09-09 new_deaths      840      959      119 0.13229572
## 109 2020-09-06 new_deaths      661      580       81 0.13053989
## 110 2020-09-20 new_deaths      473      416       57 0.12823397
## 111 2020-08-09 new_deaths      856      756      100 0.12406948
## 112 2020-07-19 new_deaths      981      869      112 0.12108108
## 113 2021-03-26 new_deaths      844      951      107 0.11922006
## 114 2021-07-03 new_deaths      160      142       18 0.11920530
## 115 2021-07-07 new_deaths      239      269       30 0.11811024
## 116 2021-06-24 new_deaths      255      287       32 0.11808118
## 117 2020-08-17 new_deaths      834      742       92 0.11675127
## 118 2020-07-20 new_deaths     1028      915      113 0.11631498
## 119 2020-09-28 new_deaths      518      462       56 0.11428571
## 120 2020-08-04 new_deaths     1217     1087      130 0.11284722
## 121 2020-07-27 new_deaths     1115      997      118 0.11174242
## 122 2020-09-17 new_deaths      698      778       80 0.10840108
## 123 2021-06-04 new_deaths      522      469       53 0.10696266
## 124 2020-07-25 new_deaths     1153     1036      117 0.10689813
## 125 2021-06-12 new_deaths      298      268       30 0.10600707
## 126 2020-07-05 new_deaths      571      514       57 0.10506912
## 127 2020-07-06 new_deaths      716      645       71 0.10433505
## 128 2021-05-30 new_deaths      263      237       26 0.10400000
## 129 2020-09-11 new_deaths      797      884       87 0.10350982
## 130 2021-06-05 new_deaths      319      288       31 0.10214168
## 131 2020-07-09 new_deaths      883      798       85 0.10113028
## 132 2021-05-27 new_deaths      508      561       53 0.09915809
## 133 2020-09-21 new_deaths      657      596       61 0.09736632
## 134 2020-09-18 new_deaths      773      852       79 0.09723077
## 135 2020-07-04 new_deaths      572      519       53 0.09715857
## 136 2020-09-16 new_deaths      985     1085      100 0.09661836
## 137 2021-06-06 new_deaths      225      247       22 0.09322034
## 138 2020-08-06 new_deaths     1236     1126      110 0.09314141
## 139 2020-07-18 new_deaths     1001      912       89 0.09304757
## 140 2020-03-20 new_deaths      102       93        9 0.09230769
## 141 2020-10-09 new_deaths      745      816       71 0.09096733
## 142 2020-06-22 new_deaths      583      533       50 0.08960573
## 143 2021-07-01 new_deaths      216      236       20 0.08849558
## 144 2020-10-01 new_deaths      704      768       64 0.08695652
## 145 2021-06-20 new_deaths      193      177       16 0.08648649
## 146 2020-08-23 new_deaths      753      692       61 0.08442907
## 147 2021-06-30 new_deaths      247      227       20 0.08438819
## 148 2020-10-10 new_deaths      656      603       53 0.08419380
## 149 2020-09-15 new_deaths      793      862       69 0.08338369
## 150 2020-10-13 new_deaths      741      805       64 0.08279431
## 151 2021-07-02 new_deaths      265      244       21 0.08251473
## 152 2021-06-18 new_deaths      228      210       18 0.08219178
## 153 2020-08-24 new_deaths      779      718       61 0.08149633
## 154 2021-05-20 new_deaths      498      540       42 0.08092486
## 155 2021-05-25 new_deaths      491      532       41 0.08015640
## 156 2020-09-01 new_deaths      960     1040       80 0.08000000
## 157 2020-09-03 new_deaths      882      954       72 0.07843137
## 158 2021-06-15 new_deaths      311      336       25 0.07727975
## 159 2021-03-25 new_deaths      762      823       61 0.07697161
## 160 2020-09-27 new_deaths      489      453       36 0.07643312
## 161 2020-09-12 new_deaths      599      646       47 0.07550201
## 162 2020-08-31 new_deaths      688      638       50 0.07541478
## 163 2020-09-25 new_deaths      705      760       55 0.07508532
## 164 2020-06-14 new_deaths      491      456       35 0.07391763
## 165 2020-07-17 new_deaths     1097     1020       77 0.07274445
## 166 2020-08-18 new_deaths     1034     1112       78 0.07269338
## 167 2020-09-29 new_deaths      862      927       65 0.07266629
## 168 2020-07-24 new_deaths     1337     1244       93 0.07206509
## 169 2021-06-26 new_deaths      188      175       13 0.07162534
## 170 2020-10-07 new_deaths      791      849       58 0.07073171
## 171 2021-02-16 new_deaths     1579     1694      115 0.07027192
## 172 2021-06-28 new_deaths      207      193       14 0.07000000
## 173 2020-10-25 new_deaths      654      610       44 0.06962025
## 174 2021-04-16 new_deaths      755      809       54 0.06905371
## 175 2021-05-09 new_deaths      383      358       25 0.06747638
## 176 2021-03-14 new_deaths      635      594       41 0.06672091
## 177 2021-03-30 new_deaths      725      775       50 0.06666667
## 178 2021-04-05 new_deaths      404      378       26 0.06649616
## 179 2020-03-24 new_deaths      234      219       15 0.06622517
## 180 2020-07-15 new_deaths     1171     1096       75 0.06616674
## 181 2021-06-16 new_deaths      331      310       21 0.06552262
## 182 2020-09-14 new_deaths      538      504       34 0.06525912
## 183 2021-05-18 new_deaths      615      656       41 0.06451613
## 184 2020-07-21 new_deaths     1332     1251       81 0.06271777
## 185 2021-05-04 new_deaths      698      743       45 0.06245663
## 186 2021-05-21 new_deaths      590      628       38 0.06239737
## 187 2020-08-14 new_deaths     1011     1076       65 0.06229037
## 188 2020-08-25 new_deaths      975     1037       62 0.06163022
## 189 2020-12-25 new_deaths     2489     2341      148 0.06128364
## 190 2021-07-30 new_deaths      488      459       29 0.06124604
## 191 2020-10-21 new_deaths     1046     1112       66 0.06116775
## 192 2020-07-11 new_deaths      880      828       52 0.06088993
## 193 2021-04-26 new_deaths      496      527       31 0.06060606
## 194 2020-08-01 new_deaths     1144     1077       67 0.06033318
## 195 2021-06-02 new_deaths      472      501       29 0.05960946
## 196 2020-03-25 new_deaths      312      294       18 0.05940594
## 197 2021-05-26 new_deaths      497      527       30 0.05859375
## 198 2020-06-21 new_deaths      406      383       23 0.05830165
## 199 2021-01-01 new_deaths     3181     3001      180 0.05823358
## 200 2021-04-25 new_deaths      425      401       24 0.05811138
## 201 2020-08-22 new_deaths      898      848       50 0.05727377
## 202 2020-10-17 new_deaths      666      705       39 0.05689278
## 203 2021-06-27 new_deaths      147      139        8 0.05594406
## 204 2020-08-28 new_deaths      950      899       51 0.05516495
## 205 2021-04-06 new_deaths      726      767       41 0.05492297
## 206 2020-08-20 new_deaths      974      922       52 0.05485232
## 207 2020-10-02 new_deaths      772      815       43 0.05419030
## 208 2021-05-02 new_deaths      408      387       21 0.05283019
## 209 2021-04-08 new_deaths      741      781       40 0.05256242
## 210 2020-07-22 new_deaths     1204     1143       61 0.05198125
## 211 2020-06-29 new_deaths      537      510       27 0.05157593
## 212 2021-03-16 new_deaths      889      936       47 0.05150685
## 213 2021-02-19 new_deaths     2138     2251      113 0.05149237
## 214 2021-05-16 new_deaths      419      398       21 0.05140759
## 215 2021-06-10 new_deaths      381      401       20 0.05115090
## 216 2021-04-19 new_deaths      503      478       25 0.05096840
## 217 2020-06-27 new_deaths      585      556       29 0.05083260
## 218 2020-05-04 new_deaths     1341     1275       66 0.05045872
## 219 2021-07-21 new_deaths      387      407       20 0.05037783
## 220 2021-03-09 new_deaths     1067     1122       55 0.05025126
## 221 2020-11-07  new_cases   131351    95671    35680 0.31433077
## 222 2021-07-29  new_cases   100196    83462    16734 0.18223001
## 223 2020-08-31  new_cases    36964    31737     5227 0.15216664
## 224 2021-07-26  new_cases    58003    51051     6952 0.12749647
## 225 2021-07-28  new_cases    95770    84435    11335 0.12580117
## 226 2020-09-01  new_cases    39422    44538     5116 0.12186756
## 227 2021-07-27  new_cases    87274    77663     9611 0.11654147
## 228 2021-03-01  new_cases    51474    45900     5574 0.11448641
## 229 2021-06-06  new_cases    10806    12103     1297 0.11323061
## 230 2021-07-06  new_cases    16808    15036     1772 0.11129255
## 231 2021-06-28  new_cases    10809     9695     1114 0.10866172
## 232 2021-04-12  new_cases    60933    54867     6066 0.10476684
## 233 2021-01-02  new_cases   202831   223976    21145 0.09908460
## 234 2021-07-20  new_cases    53097    48234     4863 0.09598247
## 235 2020-07-05  new_cases    41454    45432     3978 0.09156826
## 236 2020-10-11  new_cases    43907    47898     3991 0.08694516
## 237 2020-12-26  new_cases   139718   151877    12159 0.08339649
## 238 2021-07-31  new_cases    93001    85965     7036 0.07862946
## 239 2021-04-18  new_cases    47829    51724     3895 0.07824978
## 240 2020-06-25  new_cases    52896    48970     3926 0.07708166
## 241 2020-10-10  new_cases    54532    50606     3926 0.07468280
## 242 2021-05-22  new_cases    21567    23239     1672 0.07463286
## 243 2020-05-28  new_cases    25872    24023     1849 0.07411564
## 244 2021-04-11  new_cases    49741    53464     3723 0.07214767
## 245 2021-07-12  new_cases    24378    22694     1684 0.07154997
## 246 2020-11-26  new_cases   154983   166180    11197 0.06972783
## 247 2020-07-11  new_cases    71048    66320     4728 0.06883699
## 248 2020-06-28  new_cases    42359    45369     3010 0.06862119
## 249 2020-07-13  new_cases    54767    58407     3640 0.06432573
## 250 2021-07-19  new_cases    37518    35205     2313 0.06361124
## 251 2021-02-28  new_cases    48809    51996     3187 0.06323099
## 252 2020-07-15  new_cases    74721    70325     4396 0.06061525
## 253 2021-06-05  new_cases    14629    15543      914 0.06058597
## 254 2020-10-04  new_cases    34481    36560     2079 0.05852958
## 255 2020-07-07  new_cases    61055    57638     3417 0.05757711
## 256 2020-08-09  new_cases    41301    43702     2401 0.05649212
## 257 2020-05-21  new_cases    26310    27823     1513 0.05589936
## 258 2021-06-25  new_cases    14346    13571      775 0.05552173
## 259 2021-07-24  new_cases    61423    58168     3255 0.05443553
## 260 2021-02-15  new_cases    55391    52487     2904 0.05383860
## 261 2021-04-24  new_cases    52189    55068     2879 0.05368414
## 262 2020-08-15  new_cases    44136    46541     2405 0.05304542
## 263 2020-07-19  new_cases    58071    61214     3143 0.05269732
## 264 2020-10-21  new_cases    73143    69480     3663 0.05136619
## 265 2020-07-01  new_cases    62056    58987     3069 0.05070925

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     FL tot_deaths  10350041   9728382   621659 0.061923090
## 2     PR tot_deaths    628469    609082    19387 0.031331234
## 3     KY tot_deaths   1849448   1839137    10311 0.005590762
## 4     IN tot_deaths   3811948   3798160    13788 0.003623602
## 5     MS tot_deaths   2215491   2207767     7724 0.003492448
## 6     AL tot_deaths   3073211   3066125     7086 0.002308393
## 7     SC tot_deaths   2563582   2568618     5036 0.001962511
## 8     NM tot_deaths   1126633   1124549     2084 0.001851472
## 9     NC tot_deaths   3458165   3454115     4050 0.001171828
## 10    PR  tot_cases  31617012  33334437  1717425 0.052883347
## 11    PA  tot_cases 273389806 270659767  2730039 0.010035994
## 12    AL  tot_cases 147055558 148145611  1090053 0.007385154
## 13    SC  tot_cases 145835188 146346674   511486 0.003501148
## 14    FL  tot_cases 578444524 576560229  1884295 0.003262835
## 15    MI  tot_cases 242865368 242316039   549329 0.002264427
## 16    FL new_deaths     40473     39179     1294 0.032491337
## 17    MS new_deaths      7791      7544      247 0.032213890
## 18    GA new_deaths     21232     21698      466 0.021709760
## 19    KY new_deaths      7479      7348      131 0.017670466
## 20    AL new_deaths     11734     11542      192 0.016497680
## 21    NM new_deaths      4446      4414       32 0.007223476
## 22    NC new_deaths     13739     13670       69 0.005034843
## 23    IN new_deaths     14058     14012       46 0.003277520
## 24    TN new_deaths     12794     12758       36 0.002817783
## 25    PR new_deaths      2591      2585        6 0.002318393
## 26    SC new_deaths      9972      9958       14 0.001404917
## 27    AL  new_cases    599948    592417     7531 0.012632038
## 28    CA  new_cases   4074510   4037808    36702 0.009048462
## 29    NC  new_cases   1064603   1056699     7904 0.007452027
## 30    WA  new_cases    479286    475881     3405 0.007129643
## 31    FL  new_cases   2659034   2641696    17338 0.006541740
## 32    KY  new_cases    488696    486115     2581 0.005295385
## 33    GA  new_cases   1190936   1185594     5342 0.004495630
## 34    MI  new_cases   1017675   1013112     4563 0.004493824
## 35    PA  new_cases   1232900   1227519     5381 0.004374052
## 36    TN  new_cases    903587    900418     3169 0.003513294
## 37    SD  new_cases    125481    125216      265 0.002114106
## 38    PR  new_cases    148067    147820      247 0.001669556
## 39    SC  new_cases    624678    623861      817 0.001308730
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 35,280
## Columns: 15
## $ date           <date> 2021-01-25, 2020-04-17, 2021-02-02, 2020-07-30, 2020-0~
## $ state          <chr> "NE", "VI", "IL", "ME", "WI", "ND", "GU", "CT", "WI", "~
## $ tot_cases      <dbl> 187923, 54, 1130917, 3910, 25480, 6602, 0, 267337, 9844~
## $ conf_cases     <dbl> NA, NA, 1130917, 3497, 22932, 6602, NA, 250915, 92712, ~
## $ prob_cases     <dbl> NA, NA, 0, 413, 2548, 0, NA, 16422, 5728, NA, 123700, N~
## $ new_cases      <dbl> 646, 1, 2304, 22, 185, 133, 0, 0, 1502, 128, 502, 0, 39~
## $ pnew_case      <dbl> 0, NA, 0, 2, 11, 0, NA, 0, 94, 0, 143, NA, 5, 154, 0, 0~
## $ tot_deaths     <dbl> 1894, 2, 21336, 123, 700, 103, 0, 7381, 1237, 5586, 111~
## $ conf_death     <dbl> NA, NA, 19306, 122, 694, NA, NA, 6049, 1228, NA, 8887, ~
## $ prob_death     <dbl> NA, NA, 2030, 1, 6, NA, NA, 1332, 9, NA, 2265, NA, NA, ~
## $ new_deaths     <dbl> 15, 1, 63, 2, 2, 0, 0, 0, 8, 0, 6, 0, 32, 30, 15, 18, 2~
## $ pnew_death     <dbl> 0, NA, 16, 0, 0, 0, NA, 0, 0, 0, 1, NA, 0, 4, 0, 0, 0, ~
## $ created_at     <chr> "01/27/2021 12:00:00 AM", "04/17/2020 04:22:39 PM", "02~
## $ consent_cases  <chr> "Not agree", NA, "Agree", "Agree", "Agree", "Agree", "N~
## $ consent_deaths <chr> "Not agree", NA, "Agree", "Agree", "Agree", "Not agree"~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 32
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-07-02        inp    18509    17110     1399 0.07855358
## 2 2021-07-31        inp    51488    48807     2681 0.05346229
## 3 2020-07-25   hosp_ped     3450     4610     1160 0.28784119
## 4 2020-08-02   hosp_ped     4092     4498      406 0.09452852
## 5 2021-07-31   hosp_ped     1313     1247       66 0.05156250
## 6 2021-07-02   hosp_ped      696      662       34 0.05007364
## 7 2021-07-02 hosp_adult    17813    16448     1365 0.07968244
## 8 2021-07-31 hosp_adult    50175    47560     2615 0.05351205

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   544475   542977     1498 0.002755064
## 2     TX        inp  2869774  2864342     5432 0.001894625
## 3     NC        inp   675079   673836     1243 0.001842963
## 4     PR        inp   153817   153545      272 0.001769900
## 5     NH   hosp_ped      330      285       45 0.146341463
## 6     ME   hosp_ped      467      516       49 0.099694812
## 7     VI   hosp_ped       31       33        2 0.062500000
## 8     KY   hosp_ped     5435     5760      325 0.058061635
## 9     KS   hosp_ped     1718     1819      101 0.057110546
## 10    DE   hosp_ped     1826     1754       72 0.040223464
## 11    NV   hosp_ped     2279     2190       89 0.039829940
## 12    AR   hosp_ped     6174     6372      198 0.031563845
## 13    WV   hosp_ped     2221     2289       68 0.030155211
## 14    IN   hosp_ped     7226     7418      192 0.026222344
## 15    NM   hosp_ped     3202     3279       77 0.023761765
## 16    ID   hosp_ped     1422     1389       33 0.023479189
## 17    MA   hosp_ped     5244     5129      115 0.022172949
## 18    AZ   hosp_ped    11698    11884      186 0.015774743
## 19    SC   hosp_ped     2805     2843       38 0.013456091
## 20    VA   hosp_ped     6956     6870       86 0.012440330
## 21    MO   hosp_ped    16702    16901      199 0.011844181
## 22    IA   hosp_ped     2469     2441       28 0.011405295
## 23    TN   hosp_ped     8139     8223       84 0.010267693
## 24    UT   hosp_ped     3369     3337       32 0.009543692
## 25    MS   hosp_ped     4255     4295       40 0.009356725
## 26    AL   hosp_ped     8314     8385       71 0.008503503
## 27    CO   hosp_ped     9706     9784       78 0.008004105
## 28    MD   hosp_ped     5209     5241       32 0.006124402
## 29    SD   hosp_ped     2503     2489       14 0.005608974
## 30    PR   hosp_ped    11806    11868       62 0.005237814
## 31    LA   hosp_ped     3659     3676       17 0.004635310
## 32    FL   hosp_ped    56499    56703      204 0.003604177
## 33    OH   hosp_ped    28273    28343       70 0.002472799
## 34    TX   hosp_ped    41536    41439       97 0.002338054
## 35    OK   hosp_ped    12409    12436       27 0.002173476
## 36    CT   hosp_ped     2467     2462        5 0.002028809
## 37    OR   hosp_ped     3144     3150        6 0.001906578
## 38    WA   hosp_ped     4613     4621        8 0.001732727
## 39    CA   hosp_ped    32309    32259       50 0.001548755
## 40    IL   hosp_ped    20519    20548       29 0.001412326
## 41    RI   hosp_ped     1454     1452        2 0.001376462
## 42    GA   hosp_ped    22950    22921       29 0.001264415
## 43    NJ   hosp_ped     9322     9311       11 0.001180701
## 44    AL hosp_adult   463714   462110     1604 0.003465021
## 45    PR hosp_adult   120801   120467      334 0.002768705
## 46    TX hosp_adult  2415904  2411369     4535 0.001878908
## 47    VI hosp_adult     1703     1700        3 0.001763150
## 48    KY hosp_adult   310588   310043      545 0.001756277
## 49    ME hosp_adult    38523    38476       47 0.001220795
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 29,378
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 16,998
## Columns: 69
## $ date                                   <date> 2021-09-01, 2021-09-01, 2021-0~
## $ MMWR_week                              <dbl> 35, 35, 35, 35, 35, 35, 35, 35,~
## $ state                                  <chr> "KS", "NY", "RP", "NC", "IN", "~
## $ Distributed                            <dbl> 3585815, 27518855, 29820, 13316~
## $ Distributed_Janssen                    <dbl> 173500, 1253900, 3800, 646500, ~
## $ Distributed_Moderna                    <dbl> 1498900, 10968420, 20800, 54326~
## $ Distributed_Pfizer                     <dbl> 1913415, 15296535, 5220, 723687~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 123084, 141459, 166527, 126963,~
## $ Distributed_Per_100k_12Plus            <dbl> 146258, 164064, 195004, 148194,~
## $ Distributed_Per_100k_18Plus            <dbl> 162029, 178401, 213809, 162641,~
## $ Distributed_Per_100k_65Plus            <dbl> 754135, 834880, 982861, 760441,~
## $ vxa                                    <dbl> 2919234, 24428883, 29007, 10495~
## $ Administered_12Plus                    <dbl> 2919103, 24426700, 29007, 10481~
## $ Administered_18Plus                    <dbl> 2734777, 22985019, 26820, 98589~
## $ Administered_65Plus                    <dbl> 825173, 5633411, 3180, 2918484,~
## $ Administered_Janssen                   <dbl> 101837, 1072305, 2256, 390218, ~
## $ Administered_Moderna                   <dbl> 1185497, 9356997, 23828, 403072~
## $ Administered_Pfizer                    <dbl> 1630976, 13991672, 2923, 607437~
## $ Administered_Unk_Manuf                 <dbl> 924, 7909, 0, 463, 23170, 19, 8~
## $ Administered_Fed_LTC                   <dbl> 90122, 441057, 0, 228485, 14339~
## $ Administered_Fed_LTC_Residents         <dbl> 45956, 211789, 0, 112435, 91660~
## $ Administered_Fed_LTC_Staff             <dbl> 28092, 156003, 0, 73210, 37398,~
## $ Administered_Fed_LTC_Unk               <dbl> 16074, 73265, 0, 42840, 14337, ~
## $ Administered_Fed_LTC_Dose1             <dbl> 50821, 263888, 0, 137030, 81403~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 24675, 119940, 0, 63622, 50214,~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 16838, 90356, 0, 42876, 21594, ~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 9308, 53592, 0, 30532, 9595, 32~
## $ Admin_Per_100k                         <dbl> 100203, 125575, 161987, 100073,~
## $ Admin_Per_100k_12Plus                  <dbl> 119065, 145629, 189687, 116651,~
## $ Admin_Per_100k_18Plus                  <dbl> 123574, 149009, 192299, 120417,~
## $ Admin_Per_100k_65Plus                  <dbl> 173543, 170909, 104812, 166666,~
## $ Recip_Administered                     <dbl> 3015591, 24362987, 29253, 10393~
## $ Administered_Dose1_Recip               <dbl> 1673114, 13136849, 16802, 58541~
## $ Administered_Dose1_Pop_Pct             <dbl> 57.4, 67.5, 93.8, 55.8, 50.2, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 1672986, 13135259, 16802, 58453~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 68.2, 78.3, 99.9, 65.1, 59.3, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 1563564, 12335911, 15524, 54900~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 70.7, 80.0, 99.9, 67.1, 61.7, 7~
## $ Administered_Dose1_Recip_65Plus        <dbl> 456535, 2951707, 1761, 1528477,~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 96.0, 89.6, 58.0, 87.3, 85.4, 8~
## $ vxc                                    <dbl> 1408917, 11725228, 14704, 48718~
## $ vxcpoppct                              <dbl> 48.4, 60.3, 82.1, 46.5, 46.4, 4~
## $ Series_Complete_12Plus                 <dbl> 1408894, 11724573, 14704, 48665~
## $ Series_Complete_12PlusPop_Pct          <dbl> 57.5, 69.9, 96.2, 54.2, 54.7, 5~
## $ vxcgte18                               <dbl> 1328055, 11080352, 13791, 46053~
## $ vxcgte18pct                            <dbl> 60.0, 71.8, 98.9, 56.2, 57.3, 5~
## $ vxcgte65                               <dbl> 394170, 2719740, 1687, 1373717,~
## $ vxcgte65pct                            <dbl> 82.9, 82.5, 55.6, 78.4, 82.8, 7~
## $ Series_Complete_Janssen                <dbl> 100534, 1019101, 2260, 383611, ~
## $ Series_Complete_Moderna                <dbl> 550051, 4326607, 11443, 1789647~
## $ Series_Complete_Pfizer                 <dbl> 757989, 6377516, 1001, 2698491,~
## $ Series_Complete_Unk_Manuf              <dbl> 343, 2004, 0, 80, 7008, 31, 757~
## $ Series_Complete_Janssen_12Plus         <dbl> 100527, 1018977, 2260, 383589, ~
## $ Series_Complete_Moderna_12Plus         <dbl> 550044, 4326446, 11443, 1789554~
## $ Series_Complete_Pfizer_12Plus          <dbl> 757980, 6377160, 1001, 2693362,~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 343, 1990, 0, 80, 7008, 31, 757~
## $ Series_Complete_Janssen_18Plus         <dbl> 100443, 1018434, 2260, 382326, ~
## $ Series_Complete_Moderna_18Plus         <dbl> 549764, 4324978, 11443, 1786935~
## $ Series_Complete_Pfizer_18Plus          <dbl> 677527, 5735029, 88, 2436020, 1~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 321, 1911, 0, 78, 6947, 30, 698~
## $ Series_Complete_Janssen_65Plus         <dbl> 16575, 168165, 221, 44400, 2774~
## $ Series_Complete_Moderna_65Plus         <dbl> 189386, 1295280, 1456, 660640, ~
## $ Series_Complete_Pfizer_65Plus          <dbl> 188040, 1255416, 10, 668639, 42~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 169, 879, 0, 38, 3493, 18, 160,~
## $ Series_Complete_FedLTC                 <dbl> 39003, 175255, 0, 90598, 61904,~
## $ Series_Complete_FedLTC_Residents       <dbl> 20959, 90116, 0, 47822, 41207, ~
## $ Series_Complete_FedLTC_Staff           <dbl> 11153, 64362, 0, 29613, 15716, ~
## $ Series_Complete_FedLTC_Unknown         <dbl> 6891, 20777, 0, 13163, 4981, 10~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   9.39e+9    1.85e+8   3.92e+7 631618       34692    
## 2 after    9.35e+9    1.84e+8   3.90e+7 628537       29988    
## 3 pctchg   4.25e-3    4.13e-3   4.79e-3      0.00488     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 29,988
## Columns: 6
## $ date       <date> 2021-01-25, 2021-02-02, 2020-07-30, 2020-06-15, 2020-07-31~
## $ state      <chr> "NE", "IL", "ME", "WI", "ND", "CT", "WI", "NV", "AL", "MI",~
## $ tot_cases  <dbl> 187923, 1130917, 3910, 25480, 6602, 267337, 98440, 324132, ~
## $ tot_deaths <dbl> 1894, 21336, 123, 700, 103, 7381, 1237, 5586, 11152, 0, 116~
## $ new_cases  <dbl> 646, 2304, 22, 185, 133, 0, 1502, 128, 502, 0, 394, 603, 33~
## $ new_deaths <dbl> 15, 63, 2, 2, 0, 0, 8, 0, 6, 0, 32, 30, 15, 18, 2, 0, 39, 0~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.06e+7    2.46e+7 531377      29378     
## 2 after  3.04e+7    2.45e+7 518452      28311     
## 3 pctchg 5.55e-3    5.50e-3      0.0243     0.0363
## 
## 
## Processed for cdcHosp:
## Rows: 28,311
## Columns: 5
## $ date       <date> 2020-07-24, 2020-07-23, 2020-07-22, 2020-07-22, 2020-07-21~
## $ state      <chr> "ND", "ND", "IA", "ND", "ND", "ND", "KY", "ND", "HI", "LA",~
## $ inp        <dbl> 52, 54, 0, 51, 46, 44, 532, 46, 44, 1521, 42, 205, 50, 841,~
## $ hosp_adult <dbl> NA, NA, 0, NA, NA, NA, 500, NA, 27, 1482, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> NA, NA, 0, NA, NA, NA, 0, NA, 0, 0, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 1.05e+11 4.47e+10 399452.    1.39e+10 708373.     4.32e+10  490082.   
## 2 after  5.02e+10 2.16e+10 337472.    6.73e+ 9 644868.     2.09e+10  419494.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.155 5.16e- 1      0.0896 5.16e- 1       0.144
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 13,362
## Columns: 9
## $ date        <date> 2021-09-01, 2021-09-01, 2021-09-01, 2021-09-01, 2021-09-0~
## $ state       <chr> "KS", "NY", "NC", "IN", "NV", "TX", "NH", "MD", "FL", "AL"~
## $ vxa         <dbl> 2919234, 24428883, 10495776, 6431733, 3213855, 30268539, 1~
## $ vxc         <dbl> 1408917, 11725228, 4871829, 3121678, 1477405, 13802230, 81~
## $ vxcpoppct   <dbl> 48.4, 60.3, 46.5, 46.4, 48.0, 47.6, 59.7, 61.6, 53.2, 38.4~
## $ vxcgte65    <dbl> 394170, 2719740, 1373717, 898666, 377734, 2913651, 222210,~
## $ vxcgte65pct <dbl> 82.9, 82.5, 78.4, 82.8, 76.2, 78.0, 87.5, 89.3, 82.3, 72.6~
## $ vxcgte18    <dbl> 1328055, 11080352, 4605359, 2961264, 1400878, 12729288, 76~
## $ vxcgte18pct <dbl> 60.0, 71.8, 56.2, 57.3, 58.7, 58.9, 69.6, 73.7, 63.2, 47.4~
## 
## Integrated per capita data file:
## Rows: 30,201
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_210902)

The pivoted file and summaries are also created:

hospAge_210902 <- cdc_daily_210902$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_210902
## # A tibble: 528,804 x 8
##    state date       name                 value confSusp adultPed age   div      
##    <chr> <date>     <chr>                <dbl> <chr>    <chr>    <chr> <chr>    
##  1 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    0-19  West Nor~
##  2 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    20-29 West Nor~
##  3 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    30-39 West Nor~
##  4 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    40-49 West Nor~
##  5 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    50-59 West Nor~
##  6 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    60-69 West Nor~
##  7 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    70-79 West Nor~
##  8 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    80+   West Nor~
##  9 ND    2020-07-24 previous_day_admiss~    NA suspect~ adult    0-19  West Nor~
## 10 ND    2020-07-24 previous_day_admiss~    NA suspect~ adult    20-29 West Nor~
## # ... with 528,794 more rows
dfPivot_210902 <- makeCaseHospDeath(dfHosp=hospAge_210902, dfCaseDeath=cdc_daily_210902$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_210902
## # A tibble: 329,742 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 329,732 more rows
# Plot for overall trends by age group
p1 <- hospAge_210902 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Aug 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

p1 + geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

p1 + geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_210902 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Aug 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

onePageCFRPlot(dfPivot_210902, keyState="FL", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="LA", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="OR", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="HI", minDate="2020-08-01")

The latest data are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211006.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211006.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211006.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210804")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210804")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210804")$dfRaw$vax
                    )

cdc_daily_211006 <- readRunCDCDaily(thruLabel="Oct 5, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 63
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths        0      143      143 2.00000000
## 2   2020-02-03 tot_deaths      244      143      101 0.52196382
## 3   2020-02-04 tot_deaths      244      143      101 0.52196382
## 4   2020-02-05 tot_deaths      244      143      101 0.52196382
## 5   2020-02-06 tot_deaths      244      143      101 0.52196382
## 6   2020-02-07 tot_deaths      244      143      101 0.52196382
## 7   2020-02-08 tot_deaths      245      144      101 0.51928021
## 8   2020-02-09 tot_deaths      245      144      101 0.51928021
## 9   2020-02-10 tot_deaths      245      144      101 0.51928021
## 10  2020-02-11 tot_deaths      245      144      101 0.51928021
## 11  2020-02-12 tot_deaths      245      144      101 0.51928021
## 12  2020-02-13 tot_deaths      245      144      101 0.51928021
## 13  2020-02-14 tot_deaths      245      144      101 0.51928021
## 14  2020-02-15 tot_deaths      245      144      101 0.51928021
## 15  2020-02-16 tot_deaths      245      144      101 0.51928021
## 16  2020-02-17 tot_deaths      245      144      101 0.51928021
## 17  2020-02-18 tot_deaths      245      144      101 0.51928021
## 18  2020-02-19 tot_deaths      246      145      101 0.51662404
## 19  2020-02-20 tot_deaths      246      145      101 0.51662404
## 20  2020-02-21 tot_deaths      246      145      101 0.51662404
## 21  2020-02-22 tot_deaths      246      145      101 0.51662404
## 22  2020-02-23 tot_deaths      246      145      101 0.51662404
## 23  2020-02-24 tot_deaths      246      145      101 0.51662404
## 24  2020-02-25 tot_deaths      246      145      101 0.51662404
## 25  2020-02-26 tot_deaths      246      145      101 0.51662404
## 26  2020-02-27 tot_deaths      247      146      101 0.51399491
## 27  2020-02-28 tot_deaths      247      146      101 0.51399491
## 28  2020-02-29 tot_deaths      248      147      101 0.51139241
## 29  2020-03-01 tot_deaths      248      147      101 0.51139241
## 30  2020-03-02 tot_deaths      254      153      101 0.49631450
## 31  2020-03-03 tot_deaths      257      156      101 0.48910412
## 32  2020-03-04 tot_deaths      259      158      101 0.48441247
## 33  2020-03-05 tot_deaths      262      160      102 0.48341232
## 34  2020-03-06 tot_deaths      266      163      103 0.48018648
## 35  2020-03-07 tot_deaths      271      168      103 0.46924829
## 36  2020-03-08 tot_deaths      276      173      103 0.45879733
## 37  2020-03-09 tot_deaths      280      179      101 0.44008715
## 38  2020-03-10 tot_deaths      286      184      102 0.43404255
## 39  2020-03-11 tot_deaths      300      198      102 0.40963855
## 40  2020-03-12 tot_deaths      307      205      102 0.39843750
## 41  2020-03-13 tot_deaths      318      216      102 0.38202247
## 42  2020-03-14 tot_deaths      332      229      103 0.36720143
## 43  2020-03-15 tot_deaths      352      249      103 0.34276206
## 44  2020-03-16 tot_deaths      373      271      102 0.31677019
## 45  2020-03-17 tot_deaths      405      301      104 0.29461756
## 46  2020-03-18 tot_deaths      476      373      103 0.24263840
## 47  2020-03-19 tot_deaths      541      437      104 0.21267894
## 48  2020-03-20 tot_deaths      643      530      113 0.19266837
## 49  2020-03-21 tot_deaths      758      644      114 0.16262482
## 50  2020-03-22 tot_deaths      893      775      118 0.14148681
## 51  2020-03-23 tot_deaths     1064      946      118 0.11741294
## 52  2020-03-24 tot_deaths     1298     1165      133 0.10799838
## 53  2020-03-25 tot_deaths     1610     1459      151 0.09840339
## 54  2020-03-26 tot_deaths     1963     1804      159 0.08441731
## 55  2020-03-27 tot_deaths     2467     2311      156 0.06529929
## 56  2020-03-28 tot_deaths     3011     2840      171 0.05845155
## 57  2020-03-29 tot_deaths     3592     3403      189 0.05403860
## 58  2020-02-02  tot_cases       20      510      490 1.84905660
## 59  2020-01-22  tot_cases        7       33       26 1.30000000
## 60  2020-01-23  tot_cases        8       35       27 1.25581395
## 61  2020-01-25  tot_cases        9       39       30 1.25000000
## 62  2020-01-24  tot_cases        9       36       27 1.20000000
## 63  2020-01-30  tot_cases       13       47       34 1.13333333
## 64  2020-01-27  tot_cases       12       43       31 1.12727273
## 65  2020-01-26  tot_cases       12       42       30 1.11111111
## 66  2020-01-29  tot_cases       13       45       32 1.10344828
## 67  2020-01-28  tot_cases       13       44       31 1.08771930
## 68  2020-01-31  tot_cases       16       51       35 1.04477612
## 69  2020-02-01  tot_cases       20       55       35 0.93333333
## 70  2020-02-14  tot_cases      617      649       32 0.05055292
## 71  2020-02-15  tot_cases      622      654       32 0.05015674
## 72  2021-07-25 new_deaths      282      136      146 0.69856459
## 73  2021-07-24 new_deaths      305      162      143 0.61241970
## 74  2021-07-18 new_deaths      170       96       74 0.55639098
## 75  2021-07-23 new_deaths      388      226      162 0.52768730
## 76  2021-08-01 new_deaths      386      240      146 0.46645367
## 77  2021-07-26 new_deaths      387      245      142 0.44936709
## 78  2021-07-31 new_deaths      422      274      148 0.42528736
## 79  2021-06-08 new_deaths      315      209      106 0.40458015
## 80  2021-06-07 new_deaths      338      500      162 0.38663484
## 81  2020-11-11 new_deaths     1516     1046      470 0.36690086
## 82  2021-07-17 new_deaths      198      138       60 0.35714286
## 83  2021-08-02 new_deaths      561      392      169 0.35466946
## 84  2021-07-19 new_deaths      264      185       79 0.35189310
## 85  2020-11-12 new_deaths     1367     1863      496 0.30712074
## 86  2020-11-10 new_deaths     1310     1761      451 0.29371540
## 87  2021-07-04 new_deaths      135      101       34 0.28813559
## 88  2021-07-05 new_deaths      141      106       35 0.28340081
## 89  2021-07-27 new_deaths      511      393      118 0.26106195
## 90  2021-07-29 new_deaths      481      370      111 0.26086957
## 91  2021-07-28 new_deaths      459      356      103 0.25276074
## 92  2021-06-17 new_deaths      268      334       66 0.21926910
## 93  2021-05-31 new_deaths      270      218       52 0.21311475
## 94  2021-07-12 new_deaths      229      186       43 0.20722892
## 95  2020-09-30 new_deaths      537      660      123 0.20551378
## 96  2021-07-11 new_deaths      145      118       27 0.20532319
## 97  2021-06-13 new_deaths      165      200       35 0.19178082
## 98  2021-07-15 new_deaths      304      251       53 0.19099099
## 99  2020-10-11 new_deaths      565      675      110 0.17741935
## 100 2021-07-10 new_deaths      154      129       25 0.17667845
## 101 2021-06-21 new_deaths      264      315       51 0.17616580
## 102 2021-07-06 new_deaths      206      173       33 0.17414248
## 103 2021-07-20 new_deaths      320      269       51 0.17317487
## 104 2020-07-13 new_deaths      867      732      135 0.16885553
## 105 2020-10-08 new_deaths      681      803      122 0.16442049
## 106 2021-06-14 new_deaths      221      260       39 0.16216216
## 107 2020-09-24 new_deaths      694      812      118 0.15670651
## 108 2020-07-26 new_deaths      938      802      136 0.15632184
## 109 2020-09-07 new_deaths      557      477       80 0.15473888
## 110 2020-08-02 new_deaths      920      789      131 0.15330603
## 111 2021-06-01 new_deaths      336      391       55 0.15130674
## 112 2021-07-09 new_deaths      271      233       38 0.15079365
## 113 2020-09-23 new_deaths      812      944      132 0.15034169
## 114 2021-06-19 new_deaths      209      180       29 0.14910026
## 115 2021-07-16 new_deaths      303      261       42 0.14893617
## 116 2021-04-11 new_deaths      430      371       59 0.14731586
## 117 2020-08-30 new_deaths      638      552       86 0.14453782
## 118 2021-07-22 new_deaths      334      386       52 0.14444444
## 119 2020-09-10 new_deaths      789      908      119 0.14024750
## 120 2020-07-12 new_deaths      865      753      112 0.13844252
## 121 2020-09-13 new_deaths      713      623       90 0.13473054
## 122 2021-05-29 new_deaths      351      307       44 0.13373860
## 123 2020-10-15 new_deaths      693      792       99 0.13333333
## 124 2021-07-03 new_deaths      162      142       20 0.13157895
## 125 2020-09-09 new_deaths      841      959      118 0.13111111
## 126 2020-09-06 new_deaths      661      580       81 0.13053989
## 127 2020-09-20 new_deaths      473      416       57 0.12823397
## 128 2020-08-09 new_deaths      857      756      101 0.12523249
## 129 2020-07-19 new_deaths      983      869      114 0.12311015
## 130 2021-03-26 new_deaths      845      951      106 0.11804009
## 131 2020-07-20 new_deaths     1029      915      114 0.11728395
## 132 2020-08-17 new_deaths      834      742       92 0.11675127
## 133 2020-09-28 new_deaths      518      462       56 0.11428571
## 134 2021-07-07 new_deaths      240      269       29 0.11394892
## 135 2020-08-04 new_deaths     1217     1087      130 0.11284722
## 136 2021-05-30 new_deaths      265      237       28 0.11155378
## 137 2021-07-30 new_deaths      513      459       54 0.11111111
## 138 2020-07-27 new_deaths     1114      997      117 0.11084794
## 139 2021-06-24 new_deaths      257      287       30 0.11029412
## 140 2021-07-02 new_deaths      272      244       28 0.10852713
## 141 2020-09-17 new_deaths      698      778       80 0.10840108
## 142 2021-06-04 new_deaths      522      469       53 0.10696266
## 143 2020-07-25 new_deaths     1153     1036      117 0.10689813
## 144 2021-06-12 new_deaths      298      268       30 0.10600707
## 145 2021-06-05 new_deaths      320      288       32 0.10526316
## 146 2020-07-05 new_deaths      571      514       57 0.10506912
## 147 2020-07-06 new_deaths      716      645       71 0.10433505
## 148 2020-09-11 new_deaths      797      884       87 0.10350982
## 149 2020-07-09 new_deaths      883      798       85 0.10113028
## 150 2020-09-21 new_deaths      657      596       61 0.09736632
## 151 2020-09-18 new_deaths      773      852       79 0.09723077
## 152 2020-07-04 new_deaths      572      519       53 0.09715857
## 153 2021-06-20 new_deaths      195      177       18 0.09677419
## 154 2020-09-16 new_deaths      985     1085      100 0.09661836
## 155 2021-05-27 new_deaths      510      561       51 0.09523810
## 156 2020-08-06 new_deaths     1236     1126      110 0.09314141
## 157 2020-07-18 new_deaths     1001      912       89 0.09304757
## 158 2021-06-26 new_deaths      192      175       17 0.09264305
## 159 2020-03-20 new_deaths      102       93        9 0.09230769
## 160 2020-10-09 new_deaths      746      816       70 0.08962868
## 161 2020-06-22 new_deaths      583      533       50 0.08960573
## 162 2020-08-23 new_deaths      756      692       64 0.08839779
## 163 2021-06-18 new_deaths      229      210       19 0.08656036
## 164 2020-10-01 new_deaths      705      768       63 0.08553971
## 165 2021-06-30 new_deaths      247      227       20 0.08438819
## 166 2020-10-10 new_deaths      656      603       53 0.08419380
## 167 2021-05-18 new_deaths      603      656       53 0.08419380
## 168 2020-09-03 new_deaths      877      954       77 0.08410705
## 169 2021-04-08 new_deaths      718      781       63 0.08405604
## 170 2020-09-15 new_deaths      793      862       69 0.08338369
## 171 2020-10-13 new_deaths      741      805       64 0.08279431
## 172 2020-08-24 new_deaths      779      718       61 0.08149633
## 173 2020-09-01 new_deaths      959     1040       81 0.08104052
## 174 2020-09-27 new_deaths      489      453       36 0.07643312
## 175 2021-05-25 new_deaths      493      532       39 0.07609756
## 176 2020-09-12 new_deaths      599      646       47 0.07550201
## 177 2020-08-31 new_deaths      688      638       50 0.07541478
## 178 2020-09-25 new_deaths      705      760       55 0.07508532
## 179 2021-06-28 new_deaths      208      193       15 0.07481297
## 180 2020-06-14 new_deaths      491      456       35 0.07391763
## 181 2020-08-18 new_deaths     1033     1112       79 0.07365967
## 182 2021-05-09 new_deaths      385      358       27 0.07267833
## 183 2020-09-29 new_deaths      862      927       65 0.07266629
## 184 2020-07-24 new_deaths     1337     1244       93 0.07206509
## 185 2021-04-05 new_deaths      406      378       28 0.07142857
## 186 2021-06-06 new_deaths      230      247       17 0.07127883
## 187 2020-07-17 new_deaths     1095     1020       75 0.07092199
## 188 2021-06-15 new_deaths      313      336       23 0.07087827
## 189 2020-10-07 new_deaths      791      849       58 0.07073171
## 190 2021-03-25 new_deaths      767      823       56 0.07044025
## 191 2021-07-01 new_deaths      220      236       16 0.07017544
## 192 2021-05-20 new_deaths      504      540       36 0.06896552
## 193 2020-10-25 new_deaths      653      610       43 0.06809184
## 194 2020-09-14 new_deaths      539      504       35 0.06711409
## 195 2021-03-14 new_deaths      635      594       41 0.06672091
## 196 2020-03-24 new_deaths      234      219       15 0.06622517
## 197 2020-07-15 new_deaths     1171     1096       75 0.06616674
## 198 2021-06-16 new_deaths      331      310       21 0.06552262
## 199 2021-03-30 new_deaths      726      775       49 0.06528981
## 200 2020-07-21 new_deaths     1335     1251       84 0.06496520
## 201 2021-03-04 new_deaths     1235     1316       81 0.06350451
## 202 2021-05-04 new_deaths      698      743       45 0.06245663
## 203 2020-08-14 new_deaths     1011     1076       65 0.06229037
## 204 2020-12-25 new_deaths     2491     2341      150 0.06208609
## 205 2020-07-11 new_deaths      881      828       53 0.06202458
## 206 2021-06-25 new_deaths      319      300       19 0.06138934
## 207 2020-10-21 new_deaths     1046     1112       66 0.06116775
## 208 2021-05-17 new_deaths      397      422       25 0.06105006
## 209 2020-08-25 new_deaths      976     1037       61 0.06060606
## 210 2021-04-26 new_deaths      496      527       31 0.06060606
## 211 2021-04-25 new_deaths      426      401       25 0.06045949
## 212 2020-08-01 new_deaths     1144     1077       67 0.06033318
## 213 2021-02-16 new_deaths     1595     1694       99 0.06020067
## 214 2020-03-25 new_deaths      312      294       18 0.05940594
## 215 2020-08-28 new_deaths      954      899       55 0.05936319
## 216 2021-05-12 new_deaths      655      695       40 0.05925926
## 217 2021-05-21 new_deaths      592      628       36 0.05901639
## 218 2021-05-26 new_deaths      497      527       30 0.05859375
## 219 2021-04-16 new_deaths      763      809       46 0.05852417
## 220 2020-06-21 new_deaths      406      383       23 0.05830165
## 221 2021-01-01 new_deaths     3181     3001      180 0.05823358
## 222 2021-02-19 new_deaths     2124     2251      127 0.05805714
## 223 2021-04-06 new_deaths      724      767       43 0.05767941
## 224 2021-06-02 new_deaths      473      501       28 0.05749487
## 225 2020-08-22 new_deaths      898      848       50 0.05727377
## 226 2021-06-10 new_deaths      379      401       22 0.05641026
## 227 2021-06-27 new_deaths      147      139        8 0.05594406
## 228 2020-08-20 new_deaths      975      922       53 0.05587770
## 229 2021-04-17 new_deaths      576      609       33 0.05569620
## 230 2021-05-02 new_deaths      409      387       22 0.05527638
## 231 2021-04-07 new_deaths      734      695       39 0.05458362
## 232 2020-10-02 new_deaths      772      815       43 0.05419030
## 233 2021-03-09 new_deaths     1064     1122       58 0.05306496
## 234 2021-03-16 new_deaths      888      936       48 0.05263158
## 235 2020-06-29 new_deaths      537      510       27 0.05157593
## 236 2020-05-04 new_deaths     1342     1275       67 0.05120367
## 237 2020-07-22 new_deaths     1203     1143       60 0.05115090
## 238 2020-06-27 new_deaths      585      556       29 0.05083260
## 239 2021-06-11 new_deaths      343      326       17 0.05082212
## 240 2021-05-19 new_deaths      570      542       28 0.05035971
## 241 2020-01-22  new_cases        7       33       26 1.30000000
## 242 2020-11-07  new_cases   131834    95671    36163 0.31790950
## 243 2020-02-03  new_cases       26       32        6 0.20689655
## 244 2021-07-29  new_cases   100649    83462    17187 0.18670259
## 245 2020-08-31  new_cases    36951    31737     5214 0.15181691
## 246 2021-07-28  new_cases    96177    84435    11742 0.13002458
## 247 2021-07-26  new_cases    58108    51051     7057 0.12929763
## 248 2020-09-01  new_cases    39455    44538     5083 0.12103390
## 249 2021-07-27  new_cases    87616    77663     9953 0.12043877
## 250 2021-06-06  new_cases    10767    12103     1336 0.11683428
## 251 2021-07-06  new_cases    16896    15036     1860 0.11649756
## 252 2021-06-28  new_cases    10878     9695     1183 0.11500510
## 253 2021-04-12  new_cases    60857    54867     5990 0.10352217
## 254 2020-10-11  new_cases    43258    47898     4640 0.10180350
## 255 2021-07-20  new_cases    53311    48234     5077 0.09999508
## 256 2021-01-02  new_cases   202798   223976    21178 0.09924691
## 257 2021-03-01  new_cases    50563    45900     4663 0.09667956
## 258 2020-07-05  new_cases    41444    45432     3988 0.09180902
## 259 2020-12-26  new_cases   139548   151877    12329 0.08461182
## 260 2021-07-31  new_cases    93240    85965     7275 0.08119193
## 261 2020-05-28  new_cases    26010    24023     1987 0.07942758
## 262 2021-04-18  new_cases    47821    51724     3903 0.07841680
## 263 2020-10-04  new_cases    33811    36560     2749 0.07812877
## 264 2020-11-26  new_cases   153909   166180    12271 0.07667243
## 265 2021-05-22  new_cases    21532    23239     1707 0.07625472
## 266 2020-06-25  new_cases    52825    48970     3855 0.07574046
## 267 2021-07-12  new_cases    24442    22694     1748 0.07416836
## 268 2021-06-05  new_cases    14444    15543     1099 0.07329843
## 269 2020-10-10  new_cases    54240    50606     3634 0.06932072
## 270 2020-06-28  new_cases    42343    45369     3026 0.06899854
## 271 2020-07-11  new_cases    71056    66320     4736 0.06894945
## 272 2021-07-19  new_cases    37654    35205     2449 0.06722574
## 273 2021-04-11  new_cases    50023    53464     3441 0.06650111
## 274 2020-07-13  new_cases    54801    58407     3606 0.06370575
## 275 2021-02-28  new_cases    48788    51996     3208 0.06366090
## 276 2021-04-24  new_cases    51747    55068     3321 0.06218228
## 277 2020-07-15  new_cases    74637    70325     4312 0.05949145
## 278 2020-05-21  new_cases    26254    27823     1569 0.05802837
## 279 2021-02-13  new_cases    80777    85590     4813 0.05786003
## 280 2020-07-07  new_cases    61062    57638     3424 0.05769166
## 281 2020-08-09  new_cases    41266    43702     2436 0.05733923
## 282 2021-07-24  new_cases    61584    58168     3416 0.05705124
## 283 2021-06-11  new_cases    13729    14527      798 0.05648358
## 284 2021-02-15  new_cases    55513    52487     3026 0.05603704
## 285 2021-06-25  new_cases    14327    13571      756 0.05419743
## 286 2020-08-15  new_cases    44116    46541     2425 0.05349835
## 287 2021-07-23  new_cases    70211    66555     3656 0.05346358
## 288 2020-07-19  new_cases    58063    61214     3151 0.05283500
## 289 2020-10-21  new_cases    73061    69480     3581 0.05024519

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     FL tot_deaths  10350964   9728382   622582 0.062012179
## 2     PR tot_deaths    628681    609082    19599 0.031668421
## 3     KY tot_deaths   1851436   1839137    12299 0.006665090
## 4     MP tot_deaths       969       964        5 0.005173306
## 5     IN tot_deaths   3814159   3798160    15999 0.004203450
## 6     CA tot_deaths  16026588  15970217    56371 0.003523539
## 7     MS tot_deaths   2215491   2207767     7724 0.003492448
## 8     AL tot_deaths   3076064   3066125     9939 0.003236305
## 9     NM tot_deaths   1127229   1124549     2680 0.002380341
## 10    NC tot_deaths   3461659   3454115     7544 0.002181679
## 11    SC tot_deaths   2563894   2568618     4724 0.001840814
## 12    PR  tot_cases  31613320  33334437  1721117 0.053000044
## 13    CO  tot_cases 128884494 126439079  2445415 0.019155419
## 14    PA  tot_cases 273389806 270659767  2730039 0.010035994
## 15    AL  tot_cases 146850606 148145611  1295005 0.008779808
## 16    SC  tot_cases 145874578 146346674   472096 0.003231086
## 17    FL  tot_cases 578339105 576560229  1778876 0.003080573
## 18    MI  tot_cases 242865368 242316039   549329 0.002264427
## 19    NE  tot_cases  58248153  58158844    89309 0.001534427
## 20    RI  tot_cases  36690249  36744702    54453 0.001483027
## 21    MP  tot_cases     49822     49883       61 0.001223610
## 22    FL new_deaths     40667     39179     1488 0.037271748
## 23    MS new_deaths      7791      7544      247 0.032213890
## 24    KY new_deaths      7510      7348      162 0.021806434
## 25    GA new_deaths     21232     21698      466 0.021709760
## 26    AL new_deaths     11772     11542      230 0.019730634
## 27    NM new_deaths      4452      4414       38 0.008572073
## 28    NC new_deaths     13776     13670      106 0.007724259
## 29    TN new_deaths     12847     12758       89 0.006951767
## 30    IN new_deaths     14084     14012       72 0.005125285
## 31    PR new_deaths      2592      2585        7 0.002704269
## 32    CA new_deaths     64106     63942      164 0.002561539
## 33    SC new_deaths      9979      9958       21 0.002106636
## 34    MP  new_cases       196       183       13 0.068601583
## 35    AL  new_cases    600718    592417     8301 0.013914603
## 36    CO  new_cases    578677    572616     6061 0.010529031
## 37    CA  new_cases   4076069   4037808    38261 0.009431003
## 38    WA  new_cases    479286    475881     3405 0.007129643
## 39    NC  new_cases   1064245   1056699     7546 0.007115699
## 40    FL  new_cases   2658193   2641696    16497 0.006225413
## 41    KY  new_cases    488931    486115     2816 0.005776138
## 42    GA  new_cases   1190936   1185594     5342 0.004495630
## 43    MI  new_cases   1017675   1013112     4563 0.004493824
## 44    PA  new_cases   1232900   1227519     5381 0.004374052
## 45    TN  new_cases    903665    900418     3247 0.003599613
## 46    SD  new_cases    125481    125216      265 0.002114106
## 47    SC  new_cases    625173    623861     1312 0.002100824
## 48    PR  new_cases    148020    147820      200 0.001352082
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 37,320
## Columns: 15
## $ date           <date> 2021-02-12, 2021-03-01, 2020-08-22, 2020-08-12, 2020-0~
## $ state          <chr> "UT", "CO", "AR", "AS", "HI", "AK", "TX", "OK", "TX", "~
## $ tot_cases      <dbl> 359641, 438745, 56199, 0, 661, 71521, 1867163, 475578, ~
## $ conf_cases     <dbl> 359641, 411869, NA, NA, NA, NA, NA, 373929, NA, 881626,~
## $ prob_cases     <dbl> 0, 26876, NA, NA, NA, NA, NA, 101649, NA, 193571, NA, 4~
## $ new_cases      <dbl> 1060, 677, 547, 0, 8, 235, 24010, 1028, 18811, 1755, 0,~
## $ pnew_case      <dbl> 0, 60, 0, 0, 0, 0, 4196, 264, 3202, 168, 0, 0, 0, 197, ~
## $ tot_deaths     <dbl> 1785, 5952, 674, 0, 17, 377, 33124, 7488, 23357, 34153,~
## $ conf_death     <dbl> 1729, 5218, NA, NA, NA, NA, NA, 6379, NA, 28965, NA, 41~
## $ prob_death     <dbl> 56, 734, NA, NA, NA, NA, NA, 1109, NA, 5188, NA, 167, N~
## $ new_deaths     <dbl> 11, 1, 11, 0, 0, 0, 345, 8, 190, 20, 0, 13, 7, 8, 37, 0~
## $ pnew_death     <dbl> 2, 0, 0, 0, 0, 0, 0, 2, 0, -7, 0, 1, NA, 0, 7, NA, 0, 0~
## $ created_at     <chr> "02/13/2021 02:50:08 PM", "03/01/2021 12:00:00 AM", "08~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", NA, "Not agree", "N/A", ~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", NA, "Not agree", "N/A", ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses on_hand_supply_therapeutic_b_bamlanivimab_courses on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses previous_week_therapeutic_a_casirivimab_imdevimab_courses_used previous_week_therapeutic_b_bamlanivimab_courses_used previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used icu_patients_confirmed_influenza icu_patients_confirmed_influenza_coverage previous_day_admission_influenza_confirmed previous_day_admission_influenza_confirmed_coverage previous_day_deaths_covid_and_influenza previous_day_deaths_covid_and_influenza_coverage previous_day_deaths_influenza previous_day_deaths_influenza_coverage total_patients_hospitalized_confirmed_influenza total_patients_hospitalized_confirmed_influenza_and_covid total_patients_hospitalized_confirmed_influenza_and_covid_coverage total_patients_hospitalized_confirmed_influenza_coverage
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 66
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference: AS

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-07-02        inp    18525    17110     1415 0.07941630
## 2 2021-07-31        inp    51524    48807     2717 0.05416073
## 3 2020-08-02   hosp_ped     4781     4498      283 0.06099795
## 4 2021-07-31   hosp_ped     1313     1247       66 0.05156250
## 5 2021-07-02   hosp_ped      696      662       34 0.05007364
## 6 2021-07-02 hosp_adult    17829    16448     1381 0.08057881
## 7 2021-07-31 hosp_adult    50211    47560     2651 0.05422876

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     GA        inp  1164508  1159071     5437 0.004679849
## 2     NC        inp   675965   673836     2129 0.003154539
## 3     AL        inp   544531   542977     1554 0.002857910
## 4     IA        inp   182179   182542      363 0.001990563
## 5     PR        inp   153806   153545      261 0.001698384
## 6     TX        inp  2867610  2864342     3268 0.001140275
## 7     ME        inp    46767    46818       51 0.001089918
## 8     NH   hosp_ped      330      285       45 0.146341463
## 9     ME   hosp_ped      573      516       57 0.104683196
## 10    VI   hosp_ped       31       33        2 0.062500000
## 11    KS   hosp_ped     1755     1819       64 0.035814214
## 12    KY   hosp_ped     5588     5760      172 0.030313712
## 13    ID   hosp_ped     1422     1389       33 0.023479189
## 14    AR   hosp_ped     6228     6372      144 0.022857143
## 15    NM   hosp_ped     3206     3279       73 0.022513493
## 16    MA   hosp_ped     5244     5129      115 0.022172949
## 17    NV   hosp_ped     2237     2190       47 0.021233341
## 18    DE   hosp_ped     1790     1754       36 0.020316027
## 19    VA   hosp_ped     6990     6870      120 0.017316017
## 20    MS   hosp_ped     4223     4295       72 0.016905377
## 21    NJ   hosp_ped     9458     9311      147 0.015664127
## 22    SC   hosp_ped     2881     2843       38 0.013277428
## 23    UT   hosp_ped     3309     3337       28 0.008426121
## 24    AL   hosp_ped     8448     8385       63 0.007485297
## 25    LA   hosp_ped     3659     3676       17 0.004635310
## 26    PA   hosp_ped    20751    20656       95 0.004588596
## 27    IL   hosp_ped    20634    20548       86 0.004176582
## 28    OH   hosp_ped    28226    28343      117 0.004136541
## 29    TN   hosp_ped     8191     8223       32 0.003899111
## 30    AZ   hosp_ped    11929    11884       45 0.003779448
## 31    NC   hosp_ped    11220    11258       38 0.003381084
## 32    MO   hosp_ped    16846    16901       55 0.003259549
## 33    GA   hosp_ped    22986    22921       65 0.002831812
## 34    IN   hosp_ped     7398     7418       20 0.002699784
## 35    WV   hosp_ped     2294     2289        5 0.002181977
## 36    CT   hosp_ped     2467     2462        5 0.002028809
## 37    PR   hosp_ped    11845    11868       23 0.001939864
## 38    OR   hosp_ped     3144     3150        6 0.001906578
## 39    FL   hosp_ped    56811    56703      108 0.001902849
## 40    OK   hosp_ped    12413    12436       23 0.001851181
## 41    WA   hosp_ped     4613     4621        8 0.001732727
## 42    IA   hosp_ped     2445     2441        4 0.001637331
## 43    RI   hosp_ped     1454     1452        2 0.001376462
## 44    GA hosp_adult   855243   849991     5252 0.006159858
## 45    AL hosp_adult   463636   462110     1526 0.003296801
## 46    ME hosp_adult    38368    38476      108 0.002810890
## 47    IA hosp_adult   153462   153829      367 0.002388615
## 48    PR hosp_adult   120751   120467      284 0.002354716
## 49    NC hosp_adult   571992   570956     1036 0.001812856
## 50    VI hosp_adult     1703     1700        3 0.001763150
## 51    KY hosp_adult   310452   310043      409 0.001318302
## 52    TX hosp_adult  2413855  2411369     2486 0.001030418
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 31,223
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: Additional_Doses Additional_Doses_Vax_Pct Additional_Doses_18Plus Additional_Doses_18Plus_Vax_Pct Additional_Doses_50Plus Additional_Doses_50Plus_Vax_Pct Additional_Doses_65Plus Additional_Doses_65Plus_Vax_Pct Additional_Doses_Moderna Additional_Doses_Pfizer Additional_Doses_Janssen Additional_Doses_Unk_Manuf
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 63
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 19,208
## Columns: 81
## $ date                                   <date> 2021-10-05, 2021-10-05, 2021-1~
## $ MMWR_week                              <dbl> 40, 40, 40, 40, 40, 40, 40, 40,~
## $ state                                  <chr> "VA", "NV", "RP", "NE", "MI", "~
## $ Distributed                            <dbl> 12869745, 4045120, 33090, 25822~
## $ Distributed_Janssen                    <dbl> 573200, 199900, 3800, 116400, 6~
## $ Distributed_Moderna                    <dbl> 4833340, 1475340, 22900, 979980~
## $ Distributed_Pfizer                     <dbl> 7463205, 2369880, 6390, 1485870~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 150779, 131328, 184788, 133490,~
## $ Distributed_Per_100k_12Plus            <dbl> 176130, 154288, 216388, 159654,~
## $ Distributed_Per_100k_18Plus            <dbl> 192815, 169428, 237255, 177068,~
## $ Distributed_Per_100k_65Plus            <dbl> 947067, 815594, 1090640, 826431~
## $ vxa                                    <dbl> 11024264, 3443155, 31240, 22012~
## $ Administered_12Plus                    <dbl> 10992921, 3443100, 31240, 22009~
## $ Administered_18Plus                    <dbl> 10178448, 3225317, 28652, 20476~
## $ Administered_65Plus                    <dbl> 2517946, 850914, 3551, 600142, ~
## $ Administered_Janssen                   <dbl> 399119, 151785, 2333, 79234, 37~
## $ Administered_Moderna                   <dbl> 3963920, 1219801, 24444, 817158~
## $ Administered_Pfizer                    <dbl> 6655345, 2071438, 4463, 1300158~
## $ Administered_Unk_Manuf                 <dbl> 5880, 131, 0, 4746, 1616, 1270,~
## $ Administered_Fed_LTC                   <dbl> 217074, 74066, 0, 60654, 295799~
## $ Administered_Fed_LTC_Residents         <dbl> 109722, 16660, 0, 27041, 141181~
## $ Administered_Fed_LTC_Staff             <dbl> 80551, 14302, 0, 23762, 86738, ~
## $ Administered_Fed_LTC_Unk               <dbl> 26801, 43104, 0, 9851, 67880, 1~
## $ Administered_Fed_LTC_Dose1             <dbl> 121472, 50270, 0, 37443, 182161~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 58921, 9149, 0, 16713, 81899, 2~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 44628, 7977, 0, 15423, 51531, 1~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 17923, 33144, 0, 5307, 48731, 9~
## $ Admin_Per_100k                         <dbl> 129158, 111785, 174457, 113797,~
## $ Admin_Per_100k_12Plus                  <dbl> 150444, 131326, 204290, 136077,~
## $ Admin_Per_100k_18Plus                  <dbl> 152494, 135091, 205435, 140410,~
## $ Admin_Per_100k_65Plus                  <dbl> 185292, 171565, 117040, 192071,~
## $ Recip_Administered                     <dbl> 11015106, 3407219, 31501, 22079~
## $ Administered_Dose1_Recip               <dbl> 5877501, 1886012, 17827, 115491~
## $ Administered_Dose1_Pop_Pct             <dbl> 68.9, 61.2, 99.6, 59.7, 57.4, 6~
## $ Administered_Dose1_Recip_12Plus        <dbl> 5859164, 1885912, 17827, 115463~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 80.2, 71.9, 99.9, 71.4, 66.7, 7~
## $ Administered_Dose1_Recip_18Plus        <dbl> 5430306, 1763229, 16486, 107349~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 81.4, 73.9, 99.9, 73.6, 68.9, 7~
## $ Administered_Dose1_Recip_65Plus        <dbl> 1285517, 437932, 1785, 287680, ~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 94.6, 88.3, 58.8, 92.1, 89.0, 9~
## $ vxc                                    <dbl> 5209839, 1575904, 15556, 106388~
## $ vxcpoppct                              <dbl> 61.0, 51.2, 86.9, 55.0, 52.7, 5~
## $ Series_Complete_12Plus                 <dbl> 5197778, 1575865, 15556, 106379~
## $ Series_Complete_12PlusPop_Pct          <dbl> 71.1, 60.1, 99.9, 65.8, 61.2, 6~
## $ vxcgte18                               <dbl> 4823813, 1484340, 14304, 992233~
## $ vxcgte18pct                            <dbl> 72.3, 62.2, 99.9, 68.0, 63.3, 6~
## $ vxcgte65                               <dbl> 1167111, 385863, 1705, 275394, ~
## $ vxcgte65pct                            <dbl> 85.9, 77.8, 56.2, 88.1, 84.1, 8~
## $ Series_Complete_Janssen                <dbl> 390589, 149312, 2338, 79114, 37~
## $ Series_Complete_Moderna                <dbl> 1826509, 552554, 11582, 385208,~
## $ Series_Complete_Pfizer                 <dbl> 2990444, 874003, 1636, 598304, ~
## $ Series_Complete_Unk_Manuf              <dbl> 2297, 35, 0, 1260, 868, 446, 3,~
## $ Series_Complete_Janssen_12Plus         <dbl> 390495, 149308, 2338, 79096, 37~
## $ Series_Complete_Moderna_12Plus         <dbl> 1826340, 552550, 11582, 385188,~
## $ Series_Complete_Pfizer_12Plus          <dbl> 2978651, 873972, 1636, 598257, ~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 2292, 35, 0, 1258, 867, 446, 3,~
## $ Series_Complete_Janssen_18Plus         <dbl> 389060, 149270, 2338, 79040, 37~
## $ Series_Complete_Moderna_18Plus         <dbl> 1821019, 552455, 11582, 385060,~
## $ Series_Complete_Pfizer_18Plus          <dbl> 2611548, 782581, 384, 526920, 2~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 2186, 34, 0, 1213, 810, 398, 3,~
## $ Series_Complete_Janssen_65Plus         <dbl> 67735, 23902, 227, 6449, 66933,~
## $ Series_Complete_Moderna_65Plus         <dbl> 549368, 180305, 1462, 134092, 7~
## $ Series_Complete_Pfizer_65Plus          <dbl> 549284, 181636, 16, 134058, 675~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 724, 20, 0, 795, 509, 207, 3, 1~
## $ Series_Complete_FedLTC                 <dbl> 88584, 23917, 0, 23177, 113757,~
## $ Series_Complete_FedLTC_Residents       <dbl> 45746, 7416, 0, 10273, 58777, 2~
## $ Series_Complete_FedLTC_Staff           <dbl> 32916, 6273, 0, 8304, 34714, 11~
## $ Series_Complete_FedLTC_Unknown         <dbl> 9922, 10228, 0, 4600, 20266, 68~
## $ Additional_Doses                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Vax_Pct               <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_18Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_50Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_65Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_Moderna               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Pfizer                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Janssen               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Unk_Manuf             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.08e+10    2.08e+8   4.37e+7 693668       36698    
## 2 after   1.08e+10    2.07e+8   4.35e+7 690216       31722    
## 3 pctchg  4.32e- 3    4.21e-3   4.68e-3      0.00498     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 31,722
## Columns: 6
## $ date       <date> 2021-02-12, 2021-03-01, 2020-08-22, 2020-06-05, 2021-07-27~
## $ state      <chr> "UT", "CO", "AR", "HI", "AK", "TX", "OK", "TX", "GA", "MA",~
## $ tot_cases  <dbl> 359641, 438745, 56199, 661, 71521, 1867163, 475578, 1236648~
## $ tot_deaths <dbl> 1785, 5952, 674, 17, 377, 33124, 7488, 23357, 13, 17427, 21~
## $ new_cases  <dbl> 1060, 677, 547, 8, 235, 24010, 1028, 18811, 115, 1598, 1195~
## $ new_deaths <dbl> 11, 1, 11, 0, 0, 345, 8, 190, 7, 8, 37, 0, 4, 15, 31, 1, 4,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.36e+7    2.76e+7 605791      31223     
## 2 after  3.35e+7    2.75e+7 592135      30045     
## 3 pctchg 5.36e-3    5.26e-3      0.0225     0.0377
## 
## 
## Processed for cdcHosp:
## Rows: 30,045
## Columns: 5
## $ date       <date> 2021-02-02, 2021-01-30, 2021-01-28, 2021-01-26, 2021-01-21~
## $ state      <chr> "LA", "DE", "IA", "DE", "ID", "HI", "MT", "IA", "NV", "NH",~
## $ inp        <dbl> 1276, 352, 397, 368, 248, 119, 164, 548, 1763, 294, 434, 23~
## $ hosp_adult <dbl> 1260, 347, 392, 362, 243, 117, 161, 543, 1755, 291, 432, 23~
## $ hosp_ped   <dbl> 16, 5, 5, 6, 5, 2, 3, 5, 8, 3, 2, 1, 31, 3, 7, 10, 8, 5, 9,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 1.32e+11 5.71e+10 509604     1.70e+10 867745.     5.49e+10  621075.   
## 2 after  6.30e+10 2.76e+10 429668.    8.24e+ 9 788951.     2.65e+10  530761.   
## 3 pctchg 5.23e- 1 5.16e- 1      0.157 5.16e- 1      0.0908 5.17e- 1       0.145
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 15,096
## Columns: 9
## $ date        <date> 2021-10-05, 2021-10-05, 2021-10-05, 2021-10-05, 2021-10-0~
## $ state       <chr> "VA", "NV", "NE", "MI", "KS", "WV", "TN", "MA", "GA", "AL"~
## $ vxa         <dbl> 11024264, 3443155, 2201296, 10788794, 3123280, 1559989, 69~
## $ vxc         <dbl> 5209839, 1575904, 1063886, 5260265, 1501221, 726445, 31367~
## $ vxcpoppct   <dbl> 61.0, 51.2, 55.0, 52.7, 51.5, 40.5, 45.9, 68.2, 45.7, 43.1~
## $ vxcgte65    <dbl> 1167111, 385863, 275394, 1484308, 403394, 262042, 896684, ~
## $ vxcgte65pct <dbl> 85.9, 77.8, 88.1, 84.1, 84.8, 71.4, 78.4, 89.0, 76.5, 75.3~
## $ vxcgte18    <dbl> 4823813, 1484340, 992233, 4968064, 1404254, 695313, 298538~
## $ vxcgte18pct <dbl> 72.3, 62.2, 68.0, 63.3, 63.5, 48.5, 56.1, 78.9, 56.4, 52.7~
## 
## Integrated per capita data file:
## Rows: 31,935
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211006)

Additional analysis of the resulting data is conducted:

hospAge_211006 <- cdc_daily_211006$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_211006
## # A tibble: 562,014 x 8
##    state date       name                 value confSusp adultPed age   div      
##    <chr> <date>     <chr>                <dbl> <chr>    <chr>    <chr> <chr>    
##  1 LA    2021-02-02 previous_day_admiss~     1 confirm~ adult    0-19  West Sou~
##  2 LA    2021-02-02 previous_day_admiss~     8 confirm~ adult    20-29 West Sou~
##  3 LA    2021-02-02 previous_day_admiss~     7 confirm~ adult    30-39 West Sou~
##  4 LA    2021-02-02 previous_day_admiss~    20 confirm~ adult    40-49 West Sou~
##  5 LA    2021-02-02 previous_day_admiss~    23 confirm~ adult    50-59 West Sou~
##  6 LA    2021-02-02 previous_day_admiss~    26 confirm~ adult    60-69 West Sou~
##  7 LA    2021-02-02 previous_day_admiss~    48 confirm~ adult    70-79 West Sou~
##  8 LA    2021-02-02 previous_day_admiss~    30 confirm~ adult    80+   West Sou~
##  9 LA    2021-02-02 previous_day_admiss~     0 suspect~ adult    0-19  West Sou~
## 10 LA    2021-02-02 previous_day_admiss~     2 suspect~ adult    20-29 West Sou~
## # ... with 562,004 more rows
dfPivot_211006 <- makeCaseHospDeath(dfHosp=hospAge_211006, dfCaseDeath=cdc_daily_211006$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_211006
## # A tibble: 349,149 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 349,139 more rows
# Plot for overall trends by age group
p1 <- hospAge_211006 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Sep 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

p1 + geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

p1 + geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_211006 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Sep 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

onePageCFRPlot(dfPivot_211006, keyState="FL", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="LA", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="OR", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="HI", minDate="2020-08-01")

The process is converted to functional form:

createBurdenPivot <- function(lst, 
                              dataThru,
                              minDatePlot="2020-08-01", 
                              plotByState=c(state.abb, "DC")
                              ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list that includes sub-component $dfRaw$cdcHosp
    # dataThru: character string to be used for 'data through'; most commonly MMM-YY
    # minDatePlot: starting date for plots
    # plotByState: states to be facetted for plot of hospitaliztions by age (FALSE means do not create plot)

    # Convert minDatePlot to Date if passed as character
    if ("character" %in% class(minDatePlot)) minDatePlot <- as.Date(minDatePlot)
    
    # Create the hospitalized by age data
    hospAge <- lst[["dfRaw"]][["cdcHosp"]] %>%
        select(state, 
               date, 
               grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
               grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
               ) %>% 
        pivot_longer(-c(state, date)) %>% 
        mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
               adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
               age=ifelse(adultPed=="ped", 
                          "0-17", 
                          stringr::str_replace_all(string=name, pattern=".*_", replacement="")
                          ), 
               age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
               div=as.character(state.division)[match(state, state.abb)]
               )

    # Create the pivoted burden data
    dfPivot <- makeCaseHospDeath(dfHosp=hospAge, dfCaseDeath=lst[["dfPerCapita"]])

    # Plot for overall trends by age group
    p1 <- hospAge %>% 
        filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
        mutate(ageBucket=age) %>% 
        group_by(date, ageBucket) %>% 
        summarize(value=sum(value), .groups="drop") %>% 
        arrange(date) %>%
        group_by(ageBucket) %>% 
        mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
        filter(date >= minDatePlot) %>% 
        ggplot(aes(x=date, y=value7)) + 
        labs(x=NULL, 
             y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
             title=paste0("Hospital admissions for COVID by age bucket (Aug 2020 - ", dataThru, ")"), 
             subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
             ) + 
        lims(y=c(0, NA))

    # Create three main plots of hospitalized by age data
    print(p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + scale_color_discrete("Age\nbucket"))
    print(p1 + geom_col(aes(fill=ageBucket), position="stack") + scale_color_discrete("Age\nbucket"))
    print(p1 + geom_col(aes(fill=ageBucket), position="fill") + scale_color_discrete("Age\nbucket"))

    # Plot for trends by state and age group
    if (!isFALSE(plotByState)) {
        p2 <- hospAge %>% 
            filter(state %in% plotByState, !is.na(value)) %>% 
            mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
            group_by(date, state, ageBucket) %>% 
            summarize(value=sum(value), .groups="drop") %>% 
            group_by(ageBucket, state) %>% 
            mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
            filter(date >= minDatePlot) %>% 
            ggplot(aes(x=date, y=value7)) + 
            geom_line(aes(color=ageBucket, group=ageBucket)) + 
            scale_color_discrete("Age\nbucket") + 
            labs(x=NULL, 
                 y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
                 title=paste0("Hospital admissions for COVID by age bucket (Aug 2020 - ", dataThru, ")")
                 ) + 
            lims(y=c(0, NA)) + 
            facet_wrap(~state, scales="free_y")
        print(p2)
    }
    
    # Return key data (do not return plot objects)
    list(hospAge=hospAge, dfPivot=dfPivot)
    
}

burdenPivotList_211006 <- createBurdenPivot(cdc_daily_211006, dataThru="Sep 2021")
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

identical(burdenPivotList_211006$dfPivot, dfPivot_211006)
## [1] TRUE
identical(burdenPivotList_211006$hospAge, hospAge_211006)
## [1] TRUE

Plots for burden growth are also updated:

# Create data
cdcBurdenGrowth_211006 <- cdc_daily_211006$dfPerCapita %>% 
    filter(date %in% c(as.Date(max(date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for cases
p1 <- cdcBurdenGrowth_211006 %>%
    select(state, date, tcpm) %>% 
    mutate(tcpm=round(tcpm/1000)) %>%
    pivot_wider(state, names_from="date", values_from="tcpm") %>%
    tempStackPlot(yVars=c("2021-10-03"="2021-10-03", 
                          "2021-04-03"="2021-04-03", 
                          "2020-10-02"="2020-10-02"
                          ), 
                  yLab="Cumulative cases per thousand", 
                  plotTitle="Evolution of cumulative cases per thousand by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

# Run for deaths
p2 <- cdcBurdenGrowth_211006 %>%
    select(state, date, tdpm) %>% 
    mutate(tdpm=round(tdpm)) %>%
    pivot_wider(state, names_from="date", values_from="tdpm") %>%
    tempStackPlot(yVars=c("2021-10-03"="2021-10-03", 
                          "2021-04-03"="2021-04-03", 
                          "2020-10-02"="2020-10-02"
                          ), 
                  yLab="Cumulative deaths per million", 
                  plotTitle="Evolution of cumulative deaths per million by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The burden plot is converted to functional form:

cumulativeBurdenPlot <- function(lst, 
                                 keyStates=c(state.abb, "DC"), 
                                 keyDates=NULL, 
                                 ...
                                 ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file containing dfPerCapita
    # keyStates: states to include in the plot
    # keyDates: dates to include in the burden plot
    #           NULL means default to max(date)-2 from current, 6 months ago, 12 months ago)
    # ...: other arguments to pass to tempStackPlot(), most commonly colorVector
    
    # Get the list of key dates
    if (is.null(keyDates)) {
        keyDates <- as.Date(max(lst[["dfPerCapita"]]$date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")
    }
    
    # Convert to date if needed
    if (!("Date" %in% class(keyDates))) keyDates <- as.Date(keyDates)
    
    # Create data filtered for keyDates and keyStates
    burdenGrowth <- lst[["dfPerCapita"]] %>% 
        filter(date %in% all_of(keyDates), 
               state %in% all_of(keyStates)
               )

    # Create the naming vector for tempStackPlot
    vecName <- as.character(keyDates) %>% purrr::set_names(as.character(keyDates))
    
    # Create plot for cases
    p1 <- burdenGrowth %>%
        select(state, date, tcpm) %>% 
        mutate(tcpm=round(tcpm/1000)) %>%
        pivot_wider(state, names_from="date", values_from="tcpm") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="Cumulative cases per thousand", 
                      plotTitle="Evolution of cumulative cases per thousand by state", 
                      addSuffix="",
                      scaleName="Date", 
                      ...
                      )

    # Create plot for deaths
    p2 <- burdenGrowth %>%
        select(state, date, tdpm) %>% 
        mutate(tdpm=round(tdpm)) %>%
        pivot_wider(state, names_from="date", values_from="tdpm") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="Cumulative deaths per million", 
                      plotTitle="Evolution of cumulative deaths per million by state", 
                      addSuffix="",
                      scaleName="Date", 
                      ...
                      )

    # Print the plots
    gridExtra::grid.arrange(p1, p2, nrow=1)
    
    # Return the burden data
    burdenGrowth
    
}

# Run with general defaults
cumulativeBurdenPlot(cdc_daily_211006)

## # A tibble: 153 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-10-02 AK         8170         73       141          2    39         38
##  2 2020-10-02 AL       165793       4018       868         18   939        925
##  3 2020-10-02 AR        85779       1391       958          7   582        559
##  4 2020-10-02 AZ       219878       5693       552         19   730        585
##  5 2020-10-02 CA       845804      17056      3786         41  3205       3063
##  6 2020-10-02 CO        73614       2057       734          3   336        317
##  7 2020-10-02 CT        58297       4513       555          2   215        214
##  8 2020-10-02 DC        15423        629        65          1   151        136
##  9 2020-10-02 DE        21221        645       174          3   121        121
## 10 2020-10-02 FL       703540      16653      2758         65  2625       2595
## # ... with 143 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Run for specified states and dates
cumulativeBurdenPlot(cdc_daily_211006, 
                     keyStates=state.abb[state.region=="South"], 
                     keyDates=c("2021-09-30", "2021-03-31", "2020-09-30", "2020-03-31")
                     )

## # A tibble: 64 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-03-31 AL         3027         49       211          8   191         NA
##  2 2020-03-31 AR          560          8        56          1   153         NA
##  3 2020-03-31 DE          414         10        70          3    51         NA
##  4 2020-03-31 FL         6516        178       903         31  1251         NA
##  5 2020-03-31 GA         4236        130      1012         27   483         NA
##  6 2020-03-31 KY          841         29       130          7   154         NA
##  7 2020-03-31 LA         5237        239      1212         54   776         NA
##  8 2020-03-31 MD         1660         44         0          8   300         NA
##  9 2020-03-31 MS         2242        153       151         14   131         NA
## 10 2020-03-31 NC         2314         13       210          2   100         NA
## # ... with 54 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Pass a color vector
cumulativeBurdenPlot(cdc_daily_211006, 
                     keyStates=state.abb[state.region=="South"], 
                     keyDates=c("2021-09-30", "2021-06-30", "2021-03-31", 
                                "2020-12-31", "2020-09-30", "2020-06-30"
                                ), 
                     colorVector=c("lightblue", "grey", "green", "orange", "pink", "black")
                     )

## # A tibble: 96 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-06-30 AL        45865       1344      1536         23   973         NA
##  2 2020-06-30 AR        20777        270       520          5   414         NA
##  3 2020-06-30 DE        11728        509        40          2   103         NA
##  4 2020-06-30 FL       156228       3841      6527         53  7008         NA
##  5 2020-06-30 GA        81677       2805      1976         21  1659         NA
##  6 2020-06-30 KY        17073        684       267          6   579         NA
##  7 2020-06-30 LA        58095       3221      1014         22   808        499
##  8 2020-06-30 MD        67918       3316       359         13   862         NA
##  9 2020-06-30 MS        32836       1411       807         19   883         NA
## 10 2020-06-30 NC        71767       1446      2522         17  1029         NA
## # ... with 86 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>

Plots for vaccination are also updated:

# Run for fully vaccinated
tempStackPlot(cdc_daily_211006$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("vxcgte65pct"="65+", 
                      "vxcgte18pct"="18+", 
                      "vxcpoppct"="All"
                      ), 
              yLab="% Fully vaccinated", 
              plotTitle="Fully vaccinated by age cohort and state (as of early-October 2021)"
              )

# Run for first dose
tempStackPlot(cdc_daily_211006$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                      "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                      "Administered_Dose1_Pop_Pct"="All"
                      ), 
              yLab="% Receiving First Dose", 
              plotTitle="First-dose vaccinated by age cohort and state (as of early-October 2021)"
              )

# Create data
cdcVaxGrowth_211006 <- cdc_daily_211006$dfRaw$vax %>% 
    filter(date %in% c(as.Date(max(date)-lubridate::dmonths(c(0, 3, 6)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for fully vaccinated
p1 <- cdcVaxGrowth_211006 %>%
    select(state, date, vxcpoppct) %>%
    pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
    tempStackPlot(yVars=c("2021-10-05"="2021-10-05", 
                          "2021-07-05"="2021-07-05", 
                          "2021-04-05"="2021-04-05"
                          ), 
                  yLab="% Fully Vaccinated (all population)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

p2 <- cdcVaxGrowth_211006 %>%
    select(state, date, vxcgte65pct) %>%
    pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
    tempStackPlot(yVars=c("2021-10-05"="2021-10-05", 
                          "2021-07-05"="2021-07-05", 
                          "2021-04-05"="2021-04-05"
                          ), 
                  yLab="% Fully Vaccinated (65+)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

# Run for first dose
p1 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Pop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (all population)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (65+)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The process is converted to functional form:

cumulativeVaccinePlot <- function(lst, 
                                 keyStates=c(state.abb, "DC"), 
                                 keyDates=NULL, 
                                 returnData=FALSE,
                                 ...
                                 ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file containing dfPerCapita
    # keyStates: states to include in the plot
    # keyDates: dates to include in the burden plot
    #           NULL means default to max(date)-2 from current, 6 months ago, 12 months ago)
    # returnData: boolean, should the data be returned?
    # ...: other arguments to pass to tempStackPlot(), most commonly colorVector

    # Get the list of key dates
    if (is.null(keyDates)) {
        keyDates <- as.Date(max(lst[["dfRaw"]][["vax"]]$date)-2-lubridate::dmonths(c(0, 3, 6)), 
                            origin="1970-01-01"
                            )
    }
    
    # Convert to date if needed
    if (!("Date" %in% class(keyDates))) keyDates <- as.Date(keyDates)

    # Chart for fully vaccinated by state
    p5 <- tempStackPlot(lst[["dfRaw"]][["vax"]] %>% filter(date==max(keyDates), state %in% keyStates), 
                        yVars=c("vxcgte65pct"="65+", 
                                "vxcgte18pct"="18+", 
                                "vxcpoppct"="All"
                                ), 
                        yLab="% Fully vaccinated", 
                        plotTitle=paste0("Fully vaccinated by age cohort and state\n(as of ", max(keyDates), ")"), 
                        makeDotPlot=TRUE, 
                        yLims = c(0, 105)
                        )

    # Run for first dose
    p6 <- tempStackPlot(lst[["dfRaw"]][["vax"]] %>% filter(date==max(keyDates), state %in% keyStates), 
                        yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                                "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                                "Administered_Dose1_Pop_Pct"="All"
                                ), 
                        yLab="% Receiving First Dose", 
                        plotTitle=paste0("First-dose vaccinated by age cohort and state\n(as of ", 
                                         max(keyDates), 
                                         ")"
                                         ),
                        makeDotPlot=TRUE,
                        yLims=c(0, 105)
                        )

    gridExtra::grid.arrange(p5, p6, nrow=1)
    
    # Create data filtered for keyDates and keyStates
    burdenGrowth <- lst[["dfRaw"]][["vax"]] %>% 
        filter(date %in% all_of(keyDates), 
               state %in% all_of(keyStates)
               )

    # Create the naming vector for tempStackPlot
    vecName <- as.character(keyDates) %>% purrr::set_names(as.character(keyDates))
    
    # Run for fully vaccinated
    p1 <- burdenGrowth %>%
        select(state, date, vxcpoppct) %>%
        pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% Fully Vaccinated (all population)", 
                      plotTitle="Evolution of fully vaccinated rate by state", 
                      ...
                      )

    p2 <- burdenGrowth %>%
        select(state, date, vxcgte65pct) %>%
        pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% Fully Vaccinated (65+)", 
                      plotTitle="Evolution of fully vaccinated rate by state", 
                      ...
                      )

    gridExtra::grid.arrange(p1, p2, nrow=1)

    # Run for first dose
    p3 <- burdenGrowth %>%
        select(state, date, Administered_Dose1_Pop_Pct) %>%
        pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% First-dose (all population)", 
                      plotTitle="Evolution of first dose rate by state", 
                      ...
                      )

    p4 <- burdenGrowth %>%
        select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
        pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% First-dose (65+)", 
                      plotTitle="Evolution of first dose rate by state", 
                      ...
                      )

    gridExtra::grid.arrange(p3, p4, nrow=1)
    
    # Return the burden data
    if(isTRUE(returnData)) burdenGrowth
    
}


# Run with general defaults
cumulativeVaccinePlot(cdc_daily_211006)

# Run for specified states and dates
cumulativeVaccinePlot(cdc_daily_211006, 
                      keyStates=state.abb[state.region=="South"], 
                      keyDates=c("2021-09-30", "2021-06-30", "2021-03-31", "2020-12-31")
                      )

# Pass a color vector
cumulativeVaccinePlot(cdc_daily_211006, 
                      keyStates=state.abb[state.region=="South"], 
                      keyDates=c("2021-09-30", "2021-08-31", "2021-07-31", 
                                 "2021-06-30", "2021-05-31", "2021-04-30"
                                 ), 
                      colorVector=c("lightblue", "grey", "green", "orange", "pink", "black")
                      )

The functions are integrated for a post-processing capability:

postProcessCDCDaily <- function(lst, 
                                dataThruLabel,
                                keyStates=c(state.abb, "DC"), 
                                keyDatesBurden=NULL, 
                                keyDatesVaccine=NULL,
                                ...
                                ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file from readRunCDCDaily
    # dataThruLabel: label for when the hospital data are through
    # keyStates: the list of states to be plotted (burden data will be created for all states)
    # keyDatesBurden: key dates to use for the burden plots (NULL means generate automatically)
    # keyDatesVaccine: key dates to use for the vaccine plots (NULL means generate automatically)
    # ...: other arguments passed through to cumulativeBurdenPlot()
    
    # Create the burden data
    burdenPivotList <- createBurdenPivot(lst, dataThru=dataThruLabel)

    # Create the cumulative burden plots
    cumulativeBurdenPlot(lst, 
                         keyStates=keyStates, 
                         keyDates=keyDatesBurden, 
                         ...
                         )
    
    # Create the cumulative vaccines data
    cumulativeVaccinePlot(lst, 
                          keyStates=keyStates, 
                          keyDates=keyDatesVaccine, 
                          ...
                          )
    
}

# Example code
postProcessCDCDaily(cdc_daily_211006, 
                    dataThruLabel="Sep 2021", 
                    keyStates=state.abb[state.region=="South"], 
                    keyDatesBurden=c("2021-09-30", "2021-03-30", "2020-09-30", "2020-03-31"), 
                    keyDatesVaccine=c("2021-09-30", "2021-07-31", "2021-05-31", "2021-03-31")
                    )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

Data from the US Census is downloaded for age estimates by state. Per the documentation, AGE=85 means 85 and over, and AGE=999 means state total, while SEX=0 means total, SEX=1 means male, and SEX=2 means female:

popStateAge <- fileRead("./RInputFiles/sc-est2019-agesex-civ.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   SUMLEV = col_character(),
##   REGION = col_double(),
##   DIVISION = col_double(),
##   STATE = col_double(),
##   NAME = col_character(),
##   SEX = col_double(),
##   AGE = col_double(),
##   ESTBASE2010_CIV = col_double(),
##   POPEST2010_CIV = col_double(),
##   POPEST2011_CIV = col_double(),
##   POPEST2012_CIV = col_double(),
##   POPEST2013_CIV = col_double(),
##   POPEST2014_CIV = col_double(),
##   POPEST2015_CIV = col_double(),
##   POPEST2016_CIV = col_double(),
##   POPEST2017_CIV = col_double(),
##   POPEST2018_CIV = col_double(),
##   POPEST2019_CIV = col_double()
## )
popStateAge
## # A tibble: 13,572 x 18
##    SUMLEV REGION DIVISION STATE NAME    SEX   AGE ESTBASE2010_CIV POPEST2010_CIV
##    <chr>   <dbl>    <dbl> <dbl> <chr> <dbl> <dbl>           <dbl>          <dbl>
##  1 010         0        0     0 Unit~     0     0         3944160        3951430
##  2 010         0        0     0 Unit~     0     1         3978090        3957730
##  3 010         0        0     0 Unit~     0     2         4096939        4090621
##  4 010         0        0     0 Unit~     0     3         4119051        4111688
##  5 010         0        0     0 Unit~     0     4         4063186        4077346
##  6 010         0        0     0 Unit~     0     5         4056872        4064521
##  7 010         0        0     0 Unit~     0     6         4066412        4072904
##  8 010         0        0     0 Unit~     0     7         4030594        4042990
##  9 010         0        0     0 Unit~     0     8         4046497        4025501
## 10 010         0        0     0 Unit~     0     9         4148369        4125312
## # ... with 13,562 more rows, and 9 more variables: POPEST2011_CIV <dbl>,
## #   POPEST2012_CIV <dbl>, POPEST2013_CIV <dbl>, POPEST2014_CIV <dbl>,
## #   POPEST2015_CIV <dbl>, POPEST2016_CIV <dbl>, POPEST2017_CIV <dbl>,
## #   POPEST2018_CIV <dbl>, POPEST2019_CIV <dbl>
# Exploration of the states and ages and sexes included
popStateAge %>% pull(NAME) %>% unique() %>% sort()
##  [1] "Alabama"              "Alaska"               "Arizona"             
##  [4] "Arkansas"             "California"           "Colorado"            
##  [7] "Connecticut"          "Delaware"             "District of Columbia"
## [10] "Florida"              "Georgia"              "Hawaii"              
## [13] "Idaho"                "Illinois"             "Indiana"             
## [16] "Iowa"                 "Kansas"               "Kentucky"            
## [19] "Louisiana"            "Maine"                "Maryland"            
## [22] "Massachusetts"        "Michigan"             "Minnesota"           
## [25] "Mississippi"          "Missouri"             "Montana"             
## [28] "Nebraska"             "Nevada"               "New Hampshire"       
## [31] "New Jersey"           "New Mexico"           "New York"            
## [34] "North Carolina"       "North Dakota"         "Ohio"                
## [37] "Oklahoma"             "Oregon"               "Pennsylvania"        
## [40] "Rhode Island"         "South Carolina"       "South Dakota"        
## [43] "Tennessee"            "Texas"                "United States"       
## [46] "Utah"                 "Vermont"              "Virginia"            
## [49] "Washington"           "West Virginia"        "Wisconsin"           
## [52] "Wyoming"
popStateAge %>% pull(AGE) %>% unique() %>% sort()
##  [1]   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
## [20]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37
## [39]  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56
## [58]  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75
## [77]  76  77  78  79  80  81  82  83  84  85 999
popStateAge %>% pull(SEX) %>% unique() %>% sort()
## [1] 0 1 2

The data can then be explored for the total US population estimates over time, as well as the latest population estimates as of 2019:

# Total US population estimates
popStateAge %>%
    filter(AGE==999, NAME=="United States") %>%
    select(state=NAME, SEX, starts_with("POPEST")) %>%
    pivot_longer(-c(state, SEX)) %>%
    mutate(year=as.integer(stringr::str_extract(name, "\\d{4}")), 
           SEX=factor(SEX, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
           ) %>%
    ggplot(aes(x=factor(year))) + 
    geom_line(aes(y=value/1000000, group=SEX, color=SEX)) + 
    geom_text(aes(label=round(value/1000000, 1), 
                  y=value/1000000 + ifelse(SEX=="Male", -5, 5), 
                  color=SEX
                  )
              ) +
    lims(y=c(0, NA)) + 
    labs(x=NULL, y="Population (millions)", title="US Population Estimates by Year")

# Confirmation that US is the sum of the states
popStateAge %>%
    select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
    pivot_longer(-c(NAME, SEX, AGE)) %>%
    mutate(type=ifelse(NAME=="United States", "United States", "Component")) %>%
    group_by(type, SEX, AGE, name) %>%
    summarize(value=sum(value), .groups="drop") %>%
    pivot_wider(c(SEX, AGE, name), names_from="type", values_from="value") %>%
    mutate(diff=`United States`-Component) %>%
    arrange(-abs(diff))
## # A tibble: 2,871 x 6
##      SEX   AGE name            Component `United States`  diff
##    <dbl> <dbl> <chr>               <dbl>           <dbl> <dbl>
##  1     0     0 ESTBASE2010_CIV   3944160         3944160     0
##  2     0     0 POPEST2010_CIV    3951430         3951430     0
##  3     0     0 POPEST2011_CIV    3963092         3963092     0
##  4     0     0 POPEST2012_CIV    3926570         3926570     0
##  5     0     0 POPEST2013_CIV    3931258         3931258     0
##  6     0     0 POPEST2014_CIV    3954787         3954787     0
##  7     0     0 POPEST2015_CIV    3983981         3983981     0
##  8     0     0 POPEST2016_CIV    3954773         3954773     0
##  9     0     0 POPEST2017_CIV    3893990         3893990     0
## 10     0     0 POPEST2018_CIV    3815343         3815343     0
## # ... with 2,861 more rows
# Using POPEST2019_CIV as the key metric
popStateAge_2019 <- popStateAge %>%
    filter(NAME != "United States") %>%
    select(stateFull=NAME, sex=SEX, age=AGE, pop2019=POPEST2019_CIV) %>%
    mutate(state=c(state.abb, "DC")[match(stateFull, c(state.name, "District of Columbia"))], 
           sex=factor(sex, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
           )
popStateAge_2019
## # A tibble: 13,311 x 5
##    stateFull sex     age pop2019 state
##    <chr>     <fct> <dbl>   <dbl> <chr>
##  1 Alabama   Total     0   56901 AL   
##  2 Alabama   Total     1   58290 AL   
##  3 Alabama   Total     2   59073 AL   
##  4 Alabama   Total     3   59799 AL   
##  5 Alabama   Total     4   60294 AL   
##  6 Alabama   Total     5   59568 AL   
##  7 Alabama   Total     6   58599 AL   
##  8 Alabama   Total     7   59537 AL   
##  9 Alabama   Total     8   60023 AL   
## 10 Alabama   Total     9   60241 AL   
## # ... with 13,301 more rows
# Total Population as of 2019
popStateAge_2019 %>%
    filter(age==999) %>%
    ggplot(aes(x=fct_reorder(state, pop2019, max))) + 
    geom_text(data=~filter(., sex == "Total"), 
              aes(label=paste0(round(pop2019/1000000, 1), " (", state, ")"), y=pop2019/1000000 + 0.1), 
              size=3, 
              hjust=0
              ) +
    geom_col(data=~filter(., sex != "Total"), aes(y=pop2019/1000000, fill=sex), position="stack") + 
    coord_flip() + 
    labs(x=NULL, y="Population (millions)", title="2019 Population by State and Sex")

# Population by Age as of 2019
popStateAge_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(age) %>%
    summarize(pop2019=sum(pop2019)) %>%
    ggplot(aes(x=factor(age))) + 
    geom_text(aes(label=round(pop2019/1000000, 1), y=pop2019/1000000 + 0.1), 
              size=3, 
              hjust=0
              ) +
    geom_col(aes(y=pop2019/1000000)) + 
    labs(x=NULL, y="Population (millions)", title="2019 Population by Age") + 
    coord_flip()

Population totals as well as splits by state, age, and sex seem reasonable. Age buckets are created and plotted by state:

# Add age buckets to data
popStateAgeBucket_2019 <- popStateAge_2019 %>%
    mutate(bucket10=case_when(age==999 ~ "Total", 
                              age <= 19 ~ "0-19", 
                              age >= 80 ~ "80+", 
                              TRUE ~ paste0(floor(age/10)*10, "-", floor(age/10)*10+9)
                              ), 
           bucket03=case_when(age==999 ~ "Total",age <= 19 ~ "0-19", age >= 60 ~ "60+", TRUE ~ "20-59"),
           bucketYMO=case_when(age==999 ~ "Total",age < 18 ~ "0-17", age >= 65 ~ "65+", TRUE ~ "18-64")
           )
popStateAgeBucket_2019
## # A tibble: 13,311 x 8
##    stateFull sex     age pop2019 state bucket10 bucket03 bucketYMO
##    <chr>     <fct> <dbl>   <dbl> <chr> <chr>    <chr>    <chr>    
##  1 Alabama   Total     0   56901 AL    0-19     0-19     0-17     
##  2 Alabama   Total     1   58290 AL    0-19     0-19     0-17     
##  3 Alabama   Total     2   59073 AL    0-19     0-19     0-17     
##  4 Alabama   Total     3   59799 AL    0-19     0-19     0-17     
##  5 Alabama   Total     4   60294 AL    0-19     0-19     0-17     
##  6 Alabama   Total     5   59568 AL    0-19     0-19     0-17     
##  7 Alabama   Total     6   58599 AL    0-19     0-19     0-17     
##  8 Alabama   Total     7   59537 AL    0-19     0-19     0-17     
##  9 Alabama   Total     8   60023 AL    0-19     0-19     0-17     
## 10 Alabama   Total     9   60241 AL    0-19     0-19     0-17     
## # ... with 13,301 more rows
# Proportion by bucketYMO by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state, bucketYMO) %>%
    summarize(pop2019=sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder2(state, .x=bucketYMO, .y=pop2019, .fun=function(x, y) -sum(y[x=="0-17"])/sum(y)))) + 
    geom_col(aes(y=pop2019, fill=fct_rev(bucketYMO)), position="fill") + 
    coord_flip() + 
    labs(x=NULL, y="Proportion of 2019 population", title="Age distribution by state") + 
    scale_fill_discrete("Age Bucket")

# Proportion by bucket10 by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state, bucket10) %>%
    summarize(pop2019=sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder2(state, .x=bucket10, .y=pop2019, .fun=function(x, y) -sum(y[x=="0-19"])/sum(y)))) + 
    geom_col(aes(y=pop2019, fill=fct_rev(bucket10)), position="fill") + 
    coord_flip() + 
    labs(x=NULL, y="Proportion of 2019 population", title="Age distribution by state") + 
    scale_fill_discrete("Age Bucket")

# Mean age by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state) %>%
    summarize(ageMean=sum(age*pop2019)/sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder(state, -ageMean))) + 
    geom_text(aes(y=ageMean+0.2, label=round(ageMean, 1)), hjust=0, size=3) +
    geom_point(aes(y=ageMean)) + 
    coord_flip() + 
    labs(x=NULL, y="Average age", title="Mean age by state", subtitle="(caution that all 85+ counted as 85)") + 
    lims(y=c(0, NA))

There are meaningful differences in age distribution by state. Next steps are to incorporate per-capita metrics in to the hospitalization summaries:

# Integrate vpm in to the pivoted hospital data
burdenPivotList_211006$dfPivot %>%
    filter(name %in% c("0-19", "20-59", "60+"), state %in% c(state.abb, "DC"), !is.na(value)) %>%
    left_join(popStateAgeBucket_2019 %>%
                  filter(sex=="Total") %>%
                  group_by(state, bucket03) %>% 
                  summarize(pop2019=sum(pop2019), .groups="drop"), 
              by=c("state"="state", "name"="bucket03")
              ) %>%
    mutate(vpm=1000000*value/pop2019) %>%
    ggplot(aes(x=date, y=vpm)) + 
    geom_line(aes(group=name, color=name)) + 
    labs(x=NULL, y="Newly hospitalized per million", title="Per capita newly hospitalized by age bucket") +
    facet_wrap(~state, scales="free_y")

There is very significant variability by state that is not fully consistent with other metrics per capita such as cases and deaths. Further exploration is merited.

The hospitalized data in dfPivot was previously divided by total state population. The process is updated to use raw hospital data from hospAge:

ageMap <- popStateAgeBucket_2019 %>% 
    count(bucket10, bucket03) %>%
    filter(bucket10 != "Total") %>%
    select(-n)
ageMap
## # A tibble: 8 x 2
##   bucket10 bucket03
##   <chr>    <chr>   
## 1 0-19     0-19    
## 2 20-29    20-59   
## 3 30-39    20-59   
## 4 40-49    20-59   
## 5 50-59    20-59   
## 6 60-69    60+     
## 7 70-79    60+     
## 8 80+      60+
# Create hospitalized by age bucket by state data
hospBucketState <- burdenPivotList_211006$hospAge %>%
    left_join(ageMap, by=c("age"="bucket10")) %>%
    filter(!is.na(value)) %>%
    group_by(state, date, bucket03) %>%
    summarize(value=sum(value), .groups="drop") %>%
    filter(state %in% c(state.abb, "DC")) %>%
    left_join(popStateAgeBucket_2019 %>%
                  filter(sex=="Total") %>%
                  group_by(state, bucket03) %>% 
                  summarize(pop2019=sum(pop2019), .groups="drop"), 
              by=c("state", "bucket03")
              ) %>%
    mutate(vpm=1000000*value/pop2019) %>%
    group_by(state, bucket03) %>%
    arrange(date) %>%
    mutate(vpm7=zoo::rollmean(vpm, k=7, fill=NA), vpmcum=cumsum(vpm)) %>%
    ungroup()

hospBucketState %>%
    ggplot(aes(x=date, y=vpm7)) + 
    geom_line(aes(group=bucket03, color=bucket03)) + 
    labs(x=NULL, 
         y="Newly hospitalized per million (rolling 7-day mean)", 
         title="Per million newly hospitalized by age bucket"
         ) +
    facet_wrap(~state, scales="free_y") + 
    scale_color_discrete("Age")
## Warning: Removed 18 row(s) containing missing values (geom_path).

hospBucketState %>%
    filter(state != "ND", date >= "2020-07-15") %>%
    ggplot(aes(x=date, y=vpmcum/1000)) + 
    geom_line(aes(group=bucket03, color=bucket03)) + 
    labs(x=NULL, 
         y="Cumulative hospitalized per thousand since 2020-07-15", 
         title="Cumulative newly hospitalized per thousand by age bucket", 
         subtitle="Since 2020-07-15, excludes ND"
         ) +
    facet_wrap(~state, scales="free_y") + 
    scale_color_discrete("Age")

The process to create population data by state and age is converted to functional form:

createPopStateAge <- function(loc) {
    
    # FUNCTION ARGUMENTS:
    # loc: file location on the local computer
    
    # Read the data
    df <- fileRead(loc)

    # Confirm that states, ages, and sexes are as expected
    a1 <- all.equal(sort(c(state.name, "District of Columbia", "United States")), 
                    df %>% pull(NAME) %>% unique() %>% sort()
                    )
    print(a1)
    a2 <- all.equal(c(0:85, 999), df %>% pull(AGE) %>% unique() %>% sort())
    print(a2)
    a3 <- all.equal(0:2, df %>% pull(SEX) %>% unique() %>% sort())
    print(a3)
    if(!isTRUE(a1) | !isTRUE(a2) | !isTRUE(a3)) stop("\nUnexpected values for state, age, or sex\n")

    # Plot for total US population estimates
    p1 <- df %>%
        filter(AGE==999, NAME=="United States") %>%
        select(state=NAME, SEX, starts_with("POPEST")) %>%
        pivot_longer(-c(state, SEX)) %>%
        mutate(year=as.integer(stringr::str_extract(name, "\\d{4}")), 
               SEX=factor(SEX, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
               ) %>%
        ggplot(aes(x=factor(year))) + 
        geom_line(aes(y=value/1000000, group=SEX, color=SEX)) + 
        geom_text(aes(label=round(value/1000000, 1), 
                      y=value/1000000 + ifelse(SEX=="Male", -5, 5), 
                      color=SEX
                      )
                  ) +
        lims(y=c(0, NA)) + 
        labs(x=NULL, y="Population (millions)", title="US Population Estimates by Year")
    print(p1)

    # Confirmation that US is the sum of the states
    dfCheckState <- df %>%
        select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
        pivot_longer(-c(NAME, SEX, AGE)) %>%
        mutate(type=ifelse(NAME=="United States", "United States", "Component")) %>%
        group_by(type, SEX, AGE, name) %>%
        summarize(value=sum(value), .groups="drop") %>%
        pivot_wider(c(SEX, AGE, name), names_from="type", values_from="value") %>%
        mutate(diff=`United States`-Component) %>%
        arrange(-abs(diff))
    if(max(abs(dfCheckState$diff)) > 0) {
        print(dfCheckState)
        stop("\nUS total is not the sum of the states and DC\n")
    } else {
        cat("\nUS total is the sum of the states and DC\n\n")
    }
    
    # Confirmation that age 999 is the sum of all ages
    dfCheckAge <- df %>%
        select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
        pivot_longer(-c(NAME, SEX, AGE)) %>%
        mutate(type=ifelse(AGE==999, "Total", "Component")) %>%
        group_by(type, SEX, NAME, name) %>%
        summarize(value=sum(value), .groups="drop") %>%
        pivot_wider(c(SEX, NAME, name), names_from="type", values_from="value") %>%
        mutate(diff=Total-Component) %>%
        arrange(-abs(diff))
    if(max(abs(dfCheckAge$diff)) > 0) {
        print(dfCheckAge)
        stop("\nAge 999 total is not the sum of the ages\n")
    } else {
        cat("\nAge 999 total is the sum of the ages\n\n")
    }

    # Confirmation that sex 0 is the sum of all sexes
    dfCheckSex <- df %>%
        select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
        pivot_longer(-c(NAME, SEX, AGE)) %>%
        mutate(type=ifelse(SEX==0, "Total", "Component")) %>%
        group_by(type, AGE, NAME, name) %>%
        summarize(value=sum(value), .groups="drop") %>%
        pivot_wider(c(AGE, NAME, name), names_from="type", values_from="value") %>%
        mutate(diff=Total-Component) %>%
        arrange(-abs(diff))
    if(max(abs(dfCheckSex$diff)) > 0) {
        print(dfCheckSex)
        stop("\nSex 0 total is not the sum of the sexes\n")
    } else {
        cat("\nSex 0 total is the sum of the sexes\n\n")
    }

    # Return the data
    df
    
}

createPopStateAge("./RInputFiles/sc-est2019-agesex-civ.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   SUMLEV = col_character(),
##   REGION = col_double(),
##   DIVISION = col_double(),
##   STATE = col_double(),
##   NAME = col_character(),
##   SEX = col_double(),
##   AGE = col_double(),
##   ESTBASE2010_CIV = col_double(),
##   POPEST2010_CIV = col_double(),
##   POPEST2011_CIV = col_double(),
##   POPEST2012_CIV = col_double(),
##   POPEST2013_CIV = col_double(),
##   POPEST2014_CIV = col_double(),
##   POPEST2015_CIV = col_double(),
##   POPEST2016_CIV = col_double(),
##   POPEST2017_CIV = col_double(),
##   POPEST2018_CIV = col_double(),
##   POPEST2019_CIV = col_double()
## )
## [1] TRUE
## [1] TRUE
## [1] TRUE

## 
## US total is the sum of the states and DC
## 
## 
## Age 999 total is the sum of the ages
## 
## 
## Sex 0 total is the sum of the sexes
## # A tibble: 13,572 x 18
##    SUMLEV REGION DIVISION STATE NAME    SEX   AGE ESTBASE2010_CIV POPEST2010_CIV
##    <chr>   <dbl>    <dbl> <dbl> <chr> <dbl> <dbl>           <dbl>          <dbl>
##  1 010         0        0     0 Unit~     0     0         3944160        3951430
##  2 010         0        0     0 Unit~     0     1         3978090        3957730
##  3 010         0        0     0 Unit~     0     2         4096939        4090621
##  4 010         0        0     0 Unit~     0     3         4119051        4111688
##  5 010         0        0     0 Unit~     0     4         4063186        4077346
##  6 010         0        0     0 Unit~     0     5         4056872        4064521
##  7 010         0        0     0 Unit~     0     6         4066412        4072904
##  8 010         0        0     0 Unit~     0     7         4030594        4042990
##  9 010         0        0     0 Unit~     0     8         4046497        4025501
## 10 010         0        0     0 Unit~     0     9         4148369        4125312
## # ... with 13,562 more rows, and 9 more variables: POPEST2011_CIV <dbl>,
## #   POPEST2012_CIV <dbl>, POPEST2013_CIV <dbl>, POPEST2014_CIV <dbl>,
## #   POPEST2015_CIV <dbl>, POPEST2016_CIV <dbl>, POPEST2017_CIV <dbl>,
## #   POPEST2018_CIV <dbl>, POPEST2019_CIV <dbl>